The reason for this question is that there are some multilingual keyboards where a given key sends a different keycode. For instance, an SP-LA keyboard has the greater than and less than key just to the right of the left shift, making it an ideal candidate for some keyboard control while playing. Yet, if I use the KeyCode.Less to read a GetKeyDown event, it does not work. For all practical purposes, the keyboard is sending to the game any other key code, except the wanted one for Less.
A small routine that reads the key code of the key pressed and reports back what key it thinks has been pressed would be very useful.
And, of course, this problem occurs with several brands and models of keyboards so it is not that my keyboard is malfunctioning
you could always just use the input manager and let peeps change the controls themselves
Sure... Except that it raises the same error: the keycode sent by the keyboard does not correspond to what Unity believes it should be. You press the Less key, the operating system understand it and prints the less sign in all apps, but for Unity it is as if you've pressed any other key.
// Detects keys pressed and prints their keycode
function OnGUI() {
var e : Event = Event.current;
if (e.isKey) {
Debug.Log("Detected key code: " + e.keyCode);
}
}
If you check the keyboard layout, the key right next to the Left Shift is the Less/Greater, but Unity detects it as the Back Slash. This anomaly only only happens within Unity… This means that the Operating Systems “thinks” it is sending the Less/Greater key code and all software above it interpret it as such, except for Unity -which “thinks” the user pressed the Back Slash key.
My guess is that Unity has not been Locale-able yet, so this kind of problem will happen in all games exported to other countries using other layouts besides the US standard.
you could always just use the input manager and let peeps change the controls themselves
– TimBorquezSure... Except that it raises the same error: the keycode sent by the keyboard does not correspond to what Unity believes it should be. You press the Less key, the operating system understand it and prints the less sign in all apps, but for Unity it is as if you've pressed any other key.
– cmonroy