Detecting key press and key release

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

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.

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

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.