PDA

View Full Version : Detecting key press and key release



10-27-2003, 05:50 PM
Hi,
I've completed my first openGL program (under Mandrake Linux 9.0 using the Gnome desktop). I use glutKeyboardFunc(keyboard) to capture keystrokes in a function 'keyboard', and this works. One problem is that it only detects key presses. I would like to do one or both of the following:
1. I would like to detect key releases.
2. I would like to scan the keyboard at any time and read the state of the keys.

Does anyone know if there is a way of doing this.

Thanks in advance,
Ray

shinpaughp
10-27-2003, 06:26 PM
You can use the glutKeyboardUpFunc function for key releases if your GLUT_XLIB_IMPLEMENTATION >= 13 which should be the case if you are using GLUT 3.7 or greater. As far as a key map... I do not believe it is currently implemented though you could probably use an STL std::map to track current keyboard state.

10-27-2003, 07:40 PM
Thanks. I've now got glutKeyboardUpFunc working. (I am using OpenGL Programming Guide third edition (for version 1.2) and it doesn't refer to glutKeyboardUpFunc.)
Ray