# Keycodes Constants

**URL:** <https://discourse.glfw.org/t/keycodes-constants/1238>\
**Category:** support\
**Created:** [December 22, 2018, 4:31pm UTC](https://discourse.glfw.org/t/keycodes-constants/1238 "2018-12-22T16:31:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![haubna](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@haubna](https://discourse.glfw.org/u/haubna)\
**Post date:** [December 22, 2018, 4:31pm UTC](https://discourse.glfw.org/t/keycodes-constants/1238/1 "2018-12-22T16:31:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 24, 2018, 1:58pm UTC](https://discourse.glfw.org/t/keycodes-constants/1238/2 "2018-12-24T13:58:54Z")

</div>

The KeyCode constants use [virtual named keys](https://www.glfw.org/docs/latest/group__keys.html), 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](https://www.glfw.org/docs/latest/input_guide.html#input_char).

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.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [November 16, 2026, 4:13pm UTC](https://discourse.glfw.org/t/keycodes-constants/1238/3 "2026-11-16T16:13:27Z")

</div>

Closed on November 16, 2026, 4:13pm UTC


