Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Feature Request Better support for non-US standard keyboards.

Discussion in 'Input System' started by siimonhansson, Dec 15, 2023.

  1. siimonhansson

    siimonhansson

    Joined:
    May 23, 2019
    Posts:
    6
    Physical input has a lot of pros but there are also a couple of cons. One con is that additional keys outside the 105 US standard don't work (like the key between 'LShift' and 'Z' on most international layouts). In a lot of cases this results in nothing more than a minor annoyance of not being able to bind 1 or 2 keys. However, it can be an accessibility issue as some 3rd party mice and keyboards use extra keys that act more or less like virtual function keys.

    There are 5 OEM keys that work well on Windows but they don't work on other platforms such as Linux. Using both the input debugger and this make-shift debug script:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3.  
    4. public class InputPrinter : MonoBehaviour
    5. {
    6.     void Update() {
    7.         foreach (KeyCode kc in System.Enum.GetValues(typeof(KeyCode))) {
    8.             if (Input.GetKeyDown(kc)) Debug.Log($"{kc} pressed! LEGACY");
    9.         }
    10.  
    11.         foreach (Key kc in System.Enum.GetValues(typeof(Key))) {
    12.             if (kc == Key.None || kc == Key.IMESelected || Keyboard.current == null)
    13.                 continue;
    14.             if (Keyboard.current[kc].wasPressedThisFrame) Debug.Log($"{kc} pressed!");
    15.         }
    16.     }
    17. }
    You can see that pressing the button between 'LShift' and 'Z' is registered correctly on both the new and old input system if you turn off "Use Physical Keys" in the old input manager and you're using Windows. However, if you do the same test on Linux the key will only register on the old input system.

    I don't know what the best solution for this would be. Maybe there could be some sort of fallback for OEM keys where if they're not "set up" a non-physical check, akin to how the old input system did it, would be done for those keys instead?