-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL2 SDL_Keycode returns characters in current keyboard layout #10002
Comments
That is the expected behaviour. From https://wiki.libsdl.org/SDL2/SDLKeycodeLookup:
The Unicode for Q is 113. A Russian keyboard has the letter й at the same location as an English keyboard has the letter Q so if you use an English keyboard and change the keyboard layout to Russian then you will get the keycode 1081 when pressing Q. If you want to handle keys independent of the keyboard layout you should use scancodes instead of keycodes. |
If you want to know what the key would be on an en-US keyboard, you can use the function FYI, SDL3 also removes the SDL_Keycode enum and turns the type into Uint32, so it's more clear that it's not a predefined set of values, the keycode can be any printable key on the keyboard. |
FYI |
System:
Same issue using X11.
When I get SDL_Keycode from key press event I get symbols in keyboard layout at startup, this means that this doesn't correspond to a SDL_Keycode value in the enumeration.
Examples for qwertyuiop keys range:
Startup with en-US selected layout works as intended
Startup with ru-RU selected layout causes incorrect recognition of pressed buttons
Is it supposed to work like this or is it a bug since I can't recognize which buttons were pressed using SDL_Keycode enum?
The text was updated successfully, but these errors were encountered: