« Return to Thread: Status of modifier keys (shift/ctrl/alt)

Re: Status of modifier keys (shift/ctrl/alt)

by Bram Stolk-2 :: Rate this Message:

Reply to Author | View in Thread

steve wrote:
> Bill Kelly wrote:
>
>> Sorry for my n00b question - but to clarify: Does that mean
>> one can't get an event for the modifier keys themselves?
>
> Right - there is no X-windows event for one of those keys
> changing state.

Yes there is.
You get a KeyPress/KeyRelease event if you press or release Shift, or Ctrl,
or any other key.

You can test this very easily: start up 'xev' (comes standard with x11)
and press the Shift key. You will see the generated event on stdout.

I once hacked in better key handling support in glut, because I
was annoyed by the fact that I could not, e.g. use the default
Quake key 'Ctrl' which is fire, in my own programs.
Unfortunately, this was a x11-only hack, so completely non-portable.

In short, my hack came down to something like this:
< #ifndef NO_BRAM_HACK
<         /* This section was added by Bram Stolk (bram.s at chello.nl) */
<         /* to accomodate a complete keypress detection of */
<         /* all keys known to x11. We will avoid GLUT_KEY_XXX */
<         /* usage, by using the X11 key description. */
<         if (window->x11_keyboard)
<         {
<           KeySym ks;    /* x11 key symbol */
<           char *desc;   /* a descriptive string for the key */
<  
<           ks = XLookupKeysym((XKeyEvent *) & event, 0);
<           desc = XKeysymToString(ks);
<           window->x11_keyboard(desc, (event.type == KeyPress));
<         }
< #endif

This enabled me to detect a press or release of all 101 keys on my keyboard.
Even the weird windows key, and a 'menu' key :-)

   Bram


--
Bram Stolk, VR Engineer SARA, Amsterdam.   tel +31 20 592 3000

"Windows is a 32-bit extension to a 16-bit graphical shell for an 8-bit
 operating system originally coded for a 4-bit microprocessor by a 2-bit
 company that can't stand 1 bit of competition."

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

 « Return to Thread: Status of modifier keys (shift/ctrl/alt)