mojira.dev
MC-121278

Keybindings (e.g. Ctrl+A) are being mapped to the US keyboard layout even if you're using another layout

The bug

If you're using a keyboard layout where the letter A is not on the same position as on a QUERTY keyboard (for example, the French AZERTY layout), Minecraft still maps keybindings as if you were using a US/QUERTY keyboard.

How to reproduce

  1. Select the French AZERTY keyboard layout (other keyboard layouts are affected as well, see above).

  2. Type something into the chat.

  3. Press Ctrl+A (where A is the key directly to the right of the tab key).

  4. Note that nothing happens.

  5. Press Ctrl+Q (where Q is the key directly to the right of the CAPS LOCK key).

  6. Note that the text you typed into the chat is being selected.

Other keybindings are affected as well, for example F3+Q and F3+A. This also applies to Mac where for example Command+A is expected to select all text, but quits the app instead.

Code analysis

This is caused by the method glfwSetKeyCallback who returns a key code assuming a US keyboard layout.
To fix it, instead of directly testing the key code returned by glfwSetKeyCallback with the GLFW_KEY constants, it has to be converted to his printable character with the glfwGetKeyName method.

– @unknown in this comment

Linked issues

MC-93926 bug whit AZERTY mac keyboard in command blocks Resolved MC-121643 Impossible to use Ctrl+A in input boxes Resolved MC-121646 AZERTY is QWERTY in the chat box and for debug shotcuts. Resolved MC-121835 We can't select all text using Ctrl+A in chat, anvils & world creation screen Resolved MC-121958 F3+'KEY' and AZERTY keyboard Resolved

Comments 99

Works for me (Windows 10, idk if it matters)
Make sure the text field is actually selected.

It matters.

Just to be sure, do you rather mean CTRL+A in the title?
Otherwise I can also confirm that using CTRL+A to select text isn't working, and I have to use CTRL+Q instead.
The F3+A and F3+Q shorcuts are also affected and thefore swapped out.

It seems to be caused by the use of an azerty keyboard in my case

Using CTRL+A to select the text works for me. - Windows 10

Confirmed even more by digging a bit :
This is caused by the method glfwSetKeyCallback who returns a key code assuming a US keyboard layout.
To fix it, instead of directly testing the key code returned by glfwSetKeyCallback with the GLFW_KEY constants, it has to be converted to his printable character with the glfwGetKeyName method.

89 more comments

Can confirm in 23w44a.

Confirmed in 24w12a

Can confirm in 24w14a.

Can confirm in 1.20.5-rc2.

Can confirm in 1.20.6 and 24w20a

Aeldrion

(Unassigned)

Confirmed

Platform

Normal

Accessibility

accessibility, azerty, keybinding, keyboard, layout, lwjgl, qwerty

Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w45a, Minecraft 17w47b, Minecraft 17w50a, ..., 1.20.4, 24w13a, 1.20.5 Release Candidate 2, 1.20.6, 1.21

Retrieved