- Edited
Hello and sorry in advance if my terminology is off! I'm working on a menu to let the player remap keys. I've got default keys in the project's InputMap, and then buttons to remap them, where:
on _Ready
I get the InputEvent and set the label of the button to show the default key:
inputEventKey = (InputEventKey)InputMap.ActionGetEvents("jump")[0]; // get event from InputMap
Text = OS.GetKeycodeString(inputEventKey.PhysicalKeycode); // change label of button
And then on _UnhandledInput
I change it like this:
if (_event is InputEventKey e)
{
inputEventKey.Keycode = e.Keycode; // set new key in InputMap
Text = OS.GetKeycodeString(e.KeyLabel); // change label of button
...
}
This all seems to work fine, my problem is that I want to show key labels based on the player's keyboard layout. After I remap a key it does that, because I use e.KeyLabel
instead of e.Keycode
, but by default it shows the physical key name.
For example, I'm using a QWERTY keyboard and I have "Z (Physical)" in the InputMap. By default the button will say "Z", when I remap it to the (physically) same key, it will say "Y". I want it to show "Y" by default, but I don't know to get a key label just from the physical keycode/InputMap.