-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add a function to convert physical_keycode to key_label #6888
Comments
Should key names be displayed in English or in the user's language? It seems a lot of games on Windows use the keyboard layout's language. This means that if you use an English OS with a French AZERTY keyboard layout, key names will appear in French. I've seen "Press Entrée to start" in Control for instance 🙂 It's not a huge issue, and we may not have control over this anyway. Just something to keep in mind for the implementation. |
As there's no unicode for "french Enter" this could be quite cumbersome. Getting the correct codepoint would be a good start. Those wanting to go the extra mile can translate the result to the language at hand. |
For those that stumble upon this in the future, in Godot 3.x this can be solved by using OS.keyboard_get_scancode_from_physical(). This allows you to take any Physical scancode, which you can get from InputEventKey.physical_scancode and transform it into the scancode for the actual key on the keyboard. You can then easily transform that one into a key_label using OS.get_scancode_string(). I don't believe this will localize keys (Enter -> Entrée), but it will at least allow you to show the accurate key for the user's keyboard in keybinding menus. |
Describe the project you are working on
Input remapping and key/button prompts.
Describe the problem or limitation you are having in your project
It is not possible to provide accurate key prompts for players using non US QWERTY layout. This hampers the experience of many first time and returning players that now need to create a mental map of how the prompts translate to their keyboard.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
A dedicated function to convert physical_keycode to key_label would allow displaying prompts that better match the keyboard of the player.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Add a function similar to the recently added
DisplayServer.keyboard_get_keycode_from_physical(keycode)
:If this enhancement will not be used often, can it be worked around with a few lines of script?
The physical and key-label pairs can be saved whenever the player presses a new key or when they change the default keys for the action but not before it.
Is there a reason why this should be core and not an add-on in the asset library?
Discoverability and ensuring matching behavior with
InputEventKey.key_label
(when possible)The text was updated successfully, but these errors were encountered: