Does anyone else have this issue? I’m using GetBindingDisplayString() on an InputAction that has its 0 index binding set to a key such as C/X/Z. When the player’s keyboard language is currently set to something other than English I get the name of the key in that specific language. Players don’t expect this behavior, and it causes issues with fonts that only support English.
Does anyone know a way to get around this?
This is by design so that the resulting string reflects the keys as they actually appear on the player’s keyboard.
The only alternative ATM in terms of built-in mechanisms is to convert the raw binding string and disregard the actual control it leads to (which is where the locale-dependent string is coming from here). ATM can’t be done with a DisplayStringOption
(might be a useful thing to add) but can be done by using ToDisplayString
on a binding.
var action = new InputAction(binding: "<Keyboard>/a");
// Invariably prints "A" even if "A" is actually a different key
// on the player's keyboard.
Debug.Log(action.bindings[0].ToDisplayString());
As for getting an English-language string for the locale-dependent keyboard key, off the top of my head, the only thing I could think of being readily available is to convert the Unicode characters to their Unicode names. Doubt that is crazy useful but it’d make sure you’d end up with Latin alphabet characters only.
3 Likes
Thanks. It would be nice in the future to be able to choose the current behavior or to have an easy way to force it to be English. I don’t know how most games handle non-QWERTY keyboards, but usually games display the key names in the same language as the UI is localized to.
1 Like
Same issue here and this was my completely rudimentary implementation 
cameraInputDown = playerInput.actions["Camera"].GetBindingDisplayString(3);
if (cameraInputDown == "Flecha Abajo" || cameraInputDown == "Nach-Unten" || cameraInputDown == "Bas"
|| cameraInputDown == "Seta Abaixo")
{
cameraInputDown = "Down";
}
Apart from having to do something similar for all key actions per language obviously it wouldn’t work for non-latin alphabets…
This should be optional. I’m using displayString for getting sprite name in spriteAsset and it’s brokes when switching to native language because of that.