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

Re: keyboard input in X



Rikard Björklind wrote:

> I'm writing a small game for X, using PTC to draw the graphics. The
> problem is that I havn't been able to find out how to use the keyboard
> for input; PTC's functions is like readkey. I need keyboard functions
> that tell me whether a key is down or not.
> How do I do this? I guess there are X library functions, but I don't
> know where to start.

You need a routine that will keep that of what is pressed and what
isn't. This routine will have an event loop in it that will look for
KeyPress and KeyRelease events. The rough equivalent of scancodes in X
is called KeyCode, so this is what you are looking for!

> I would be very grateful if someone could give me a hint on this trivial
> matter :)

My pleasure!

-- 
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
"First they ignore you. Then they laugh at you.
Then they fight you. Then you win." -- Gandhi