Search code examples
c++opengluser-inputfreeglut

glutSpecialFunc only captures some keys


I just started with opengl, using freeglut. I'm using callback for getting user input:

glutSpecialFunc(specialKeys);   //defined: void specialKeys( int key, int x, int y ) 

Now, it only captures the control keys of the keyboard - Ctrl, Alt, F1 - F12, arrows and such. Even Enter is ignored.
I want to have my code cross-platform as of windows and linux at least. So I want to avoid using winapi if possible. On the other side, I want to avoid too many libraries, because I always have problems getting them to work. So...

  1. Does GLUT have some other callback to capture the rest of the keyboard inputs?
  2. If no, what would be the simplest possible cross-platform solution to get all the keyboard input?

Solution

  • That's what glutSpecialFunc handlers are supposed to handle.

    You want glutKeyboardFunc.