Guide to Game Development/Rendering and Game Engines/OpenGL/GLUT/Handling input

Keyboard down
This handles the function that gets called when a key is pressed down.

Keyboard up
This handles the function that gets called when a key is released.

Some invisible characters
Keyboard down and keyboard up can be used to get some 'invisible' character too like backspace and delete, see ascii table, values 0-31 and 127. For ones that don't appear there, see Special keyboard input.

Example use:

Special keyboard input
This is used for keyboard input that don't have an ascii character associated with them (e.g. Arrow up, F1).

For every key combination you should look at this reference for the name of the key you need.

There are also a reference list for the possible modifiers that you can use.

Modifiers
States:
 * GLUT_ACTIVE_SHIFT - Is shift being pressed?
 * GLUT_ACTIVE_CTRL - Is control being pressed?
 * GLUT_ACTIVE_ALT - Is alt being pressed?

Use:

Special keys
States:
 * GLUT_KEY_F1 to GLUT_KEY_F12
 * GLUT_KEY_LEFT
 * GLUT_KEY_UP
 * GLUT_KEY_RIGHT
 * GLUT_KEY_DOWN
 * GLUT_KEY_PAGE_UP
 * GLUT_KEY_PAGE_DOWN
 * GLUT_KEY_HOME
 * GLUT_KEY_END
 * GLUT_KEY_INSERT

Use:

Didn't find the key you were looking for? This is probably because it's still an ascii character (see values 0-31 and 127) and so can be accessed through keyboard down and keyboard up.

Mouse Clicked
Set-up the function that gets called when the mouse is clicked.

Parameter button:
 * button == GLUT_LEFT_BUTTON - Left mouse click
 * button == GLUT_RIGHT_BUTTON - Right mouse click
 * button == GLUT_MIDDLE_BUTTON - Middle mouse click/mouse wheel clicked
 * button == 3 - Mouse wheel scrolled up (there's another way to detect this)
 * button == 4 - Mouse wheel scrolled down (there's another way to detect this)

Parameter state:
 * state == GLUT_DOWN - The button type has been pressed down
 * state == GLUT_UP - The button type has been released

Mouse movement
This will handle when the mouse is moved.

This will contain two functions that do the following:
 * glutMotionFunc
 * Called when the mouse is moving AND the mouse is clicked (dragging).


 * glutPassiveMotionFunc
 * Called when the mouse is moving AND the mouse isn't clicked (generally moving).

Alternative
This is an alternative piece of code for if you want to call the same function for all types of mouse movement (clicked and unclicked)

Mouse Wheel Scrolling
This is an alternative way to detect mouse wheel movements (other way).