# Changing the way the keyboard coding

**URL:** <https://discourse.glfw.org/t/changing-the-way-the-keyboard-coding/1709>\
**Category:** meta\
**Created:** [December 2, 2020, 4:44pm UTC](https://discourse.glfw.org/t/changing-the-way-the-keyboard-coding/1709 "2020-12-02T16:44:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafal](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Rafal](https://discourse.glfw.org/u/Rafal)\
**Post date:** [December 2, 2020, 4:44pm UTC](https://discourse.glfw.org/t/changing-the-way-the-keyboard-coding/1709/1 "2020-12-02T16:44:07Z")

</div>

Hi,

Is it possible to change the keyboard coding in GLFW?  
If so, how can it be done?

Kind regards,  
Rafał

---

<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 2, 2020, 5:55pm UTC](https://discourse.glfw.org/t/changing-the-way-the-keyboard-coding/1709/2 "2020-12-02T17:55:56Z")

</div>

Hi @Rafal,

I don’t understand the question, could you explain what you want to achieve?

Cheers,

Doug.

---

<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 3, 2020, 12:43pm UTC](https://discourse.glfw.org/t/changing-the-way-the-keyboard-coding/1709/5 "2020-12-03T12:43:59Z")

</div>

Ah, I think I understand what you want to do now - you want to be able to translate between the [GLFW Keyboard Keys](https://www.glfw.org/docs/3.3.2/group__keys.html) and another set of key defines.

The standard approach to this is to use a key translation table, for example here is one from Dear ImGui:

> <https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_glfw.cpp#L152-L174>

Note that this ‘map’ is simply an array of size `GLFW_KEY_LAST`, so it is fast and simple to use.

You may need two such maps, one to go from GLFW to your app, and another to go in the reverse direction. GLFW itself does not implement this for you because it is intended to be a minimal API, and things which can be done by the user without modifying GLFW should be left to API user code.

Cheers,  
Doug.

---

<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 3, 2020, 2:32pm UTC](https://discourse.glfw.org/t/changing-the-way-the-keyboard-coding/1709/7 "2020-12-03T14:32:58Z")

</div>

There is no current standard for key input, but the GLFW key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60), but re-arranged to map to 7-bit ASCII for printable keys (function keys are put in the 256+ range).

There are various standards for string character representation (text), and [GLFW uses 32bit Unicode for Text input](https://www.glfw.org/docs/3.3/input_guide.html#input_char). Only ‘printable’ characters are sent to the text input callback, so `ESC` is only available through the key input as it is not printable.
