Listening for keys UP DOWN LEFT & RIGHT (open gl)

How can I listen for the keys for UP, DOWN, LEFT and RIGHT?
When I ran a test on this using the function below, I fount it hard to display the keys and I don't know their ascii values.

Can anybody help?

1
2
3
void KeyDown(unsigned char key, int x, int y)
{	cout <<key<<endl;
}  
Their values are 37-40. 37 is left, the others follow clockwise.
with glut
1
2
3
4
5
6
7
8
9
10
11
void Special_key_cb(int key, int x, int y){
  switch( key ){
  case GLUT_KEY_LEFT: //...
  case GLUT_KEY_UP: //...
  case GLUT_KEY_RIGHT: //...
  case GLUT_KEY_DOWN: //...
  }
}

//...
glutSpecialFunc(Special_key_cb);
Note that it receives an int.
Topic archived. No new replies allowed.