Keycodes Constants


So I am a bit confused about the keycodes. I can’t find a way to make sure that the key ‘z’ was pressed with ‘GLFW_KEY_Z’. Do I really have to check:
glfwGetKeyName(GLFW_KEY_UNKNOWN, scancode) == ‘z’

Is there any way to actually check if Z was pressed with the constant GLFW_KEY_Z? It would be nice to have some constants for the ‘z’ like GLFW_KEYCHAR_Z. It seems so arbitrary checking it like shown above.


The KeyCode constants use virtual named keys, so GLFW_KEY_Z represents the Z key position on a US standard Keyboard.

If you need character input for text, you should use the text input callbacks.

If, however, you want to trigger an action when the Z key is pressed, you do need to work out what the Key value is for a particular key name. One method is the one you suggest, an alternative is to translate scancodes up front and work out which is the scancode for ‘z’. If you do the later you may need to cope with the user changing keyboard (thought that’s rare). Also be aware that some keyboards may not have a ‘z’ key due to their language not using the roman alphabet.