Re: key press events & holding keys down



On Mon, 19 Mar 2012 09:21:27 -0800
Christopher Howard <christopher howard frigidcode com> wrote:
On 03/19/2012 03:34 AM, Chris Vine wrote:
Since GtkWidget objects have key-press-event and a key-release-event
signals that you can connect to (and from your explanation, clearly
you have connected to), you will probably need to explain why these
don't do what you want in order to get a meaningful answer. Most
people would monitor these in conjunction with
gdk_event_get_keyval() or gdk_event_get_keycode() and keep state.

Chris

I'm currently attempting to code a simple space combat game. In my
game it is possible (quite likely) that two keys will be held down at
the same time (especially the up arrow and another arrow) e.g. to
turn and to accelerate at the same time. Currently I monitor for key
press events as you say; the problem is that key press events are
only being generated for the last key that was pressed. So if a user
attempts to turn and accelerate at the same time, he will actually
only do one or the other, depending on which key he happened to press
last.

A key remains pressed until a key-release-event for it is received.
That is what I meant by 'keep state'.

Chris



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