The keyboard has two sets of buttons: those that can be represented using ASCII code, and those that could not. those that can be represented in ASCII return 1 byte when pressed, those that cannot return two bytes, the first of which is NULL
glut abstractly is this, providing you with two sets of functions for handling keyboard events: one for handling standard standard ASCII buttons glutKeyboardFunc , the other for handling special double-byte buttons glutSpecialFunc
a special function has constants for regular keyboard buttons:
GLUT_KEY_F1 : 0x0001, GLUT_KEY_F2 : 0x0002, GLUT_KEY_F3 : 0x0003, GLUT_KEY_F4 : 0x0004, GLUT_KEY_F5 : 0x0005, GLUT_KEY_F6 : 0x0006, GLUT_KEY_F7 : 0x0007, GLUT_KEY_F8 : 0x0008, GLUT_KEY_F9 : 0x0009, GLUT_KEY_F10 : 0x000A, GLUT_KEY_F11 : 0x000B, GLUT_KEY_F12 : 0x000C, GLUT_KEY_LEFT : 0x0064, GLUT_KEY_UP : 0x0065, GLUT_KEY_RIGHT : 0x0066, GLUT_KEY_DOWN : 0x0067, GLUT_KEY_PAGE_UP : 0x0068, GLUT_KEY_PAGE_DOWN : 0x0069, GLUT_KEY_HOME : 0x006A, GLUT_KEY_END : 0x006B, GLUT_KEY_INSERT : 0x006C, GLUT_KEY_REPEAT_OFF : 0x0000, GLUT_KEY_REPEAT_ON : 0x0001, GLUT_KEY_REPEAT_DEFAULT : 0x0002.
mouse clicks can be handled with glutMouseFunc , and mouse button constants: GLUT_LEFT_BUTTON : 0x0000, GLUT_MIDDLE_BUTTON : 0x0001, GLUT_RIGHT_BUTTON : 0x0002
glut can also handle joysticks via glutJoystickFunc , which has the following constants: GLUT_HAS_JOYSTICK : 0x0264, GLUT_OWNS_JOYSTICK : 0x0265, GLUT_JOYSTICK_BUTTONS : 0x0266, GLUT_JOYSTICK_AXES : 0x0267, GLUT_JOYSTICK_POLL_RATE : 0x0268, GLUT_JOYSTICK_BUTTON_A : 0x0001, GLUT_JOYSTICK_BUTTON_B : 0x0002, GLUT_JOYSTICK_BUTTON_C : 0x0004, GLUT_JOYSTICK_BUTTON_D :. 0x0008
if you use a gaming mouse or keyboard / joystick with a large number of buttons, you can check what each button returns by calling a button on the console, and then directly use this value in your code to see if one of these buttons is pressed