Re: key press events & holding keys down



On 03/16/2012 04:29 PM, Christopher Howard wrote:

I control the spacecraft with the arrow keys, which I do by grabbing the
GdkEventKey and then checking it against GDK_KEY_Left, GDK_KEY_Right,
and so forth. Strictly speaking what I am concerned with is whether or
not the key is held down, but this seems to work because the key event
gets repeated.

However, if one of the arrows is held down, and another arrow is
pressed, then it shuts off events for the first arrow. That's bad, of
course, because in my game the player may want to hold down two arrows
keys at once (e.g., UP for acceleration and LEFT to turn the
spacecraft). So...


Okay, having got no responses, let me ask the question in a more direct
manner: under Gtk+, how does one check whether or not any particular
keyboard key is currently pressed? I know this is possible because I
used to do it back in my ClanLib days.

I see in the Gdk docs that there is a GdkDevice object, but it is not
clear to me how to create or utilize this to such an end.

-- 
frigidcode.com
indicium.us



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]