ryanisaacg / quicksilver

A simple framework for 2D games on desktop and web
https://ryanisaacg.github.io/quicksilver
Other
782 stars 77 forks source link

How to get release key event #634

Closed mkarup closed 4 years ago

mkarup commented 4 years ago

Is there an easy way to get the state of a keyboard input event, other than when it is pressed? Sorry if I'm just being blind, but I can't seem to find an easy way to check if a key has been released. Thanks in advance! ~Malynome

lenscas commented 4 years ago

when listening to events, you get https://docs.rs/quicksilver/0.4.0-alpha0.5/quicksilver/input/enum.Event.html whenever an event fires.

You get KeyboardInput(KeyboardEvent),, every time the state of a button changed. KeyboardEvent is https://docs.rs/quicksilver/0.4.0-alpha0.5/quicksilver/input/struct.KeyboardEvent.html

So, simply use its is_down method to see if it is down or not and key() to see which key it is about