Search code examples
c#unity-game-engineinputkeyboard

Keybinds not recognized as they should Unity Input System


I'm currently working on simple movement for a fps game and right now my biggest issue is the following : Through all the follow tutorials that explain how to trigger actions of movement when certain keybinds are pressed in a C# class I always get the same weird bug being that even though I write, for instance : "Keyboard.current.zKey.isPressed" in the code, nothing happens if I press 'Z' but it works for 'W' Note that I'm working on a ZQSD keyboard instead of WASD; It's like unity automatically renders ZQSD into WASD.

I've already tried changing the Input Manager keybinds settings even though i'm using the Input System. I've also tried to change the keyboard arrangement through the classic windows option and the result is the same weirdly ? Even though my Z is supposed to be a W now ??

Thanks in advance for any advice I could use.


Solution

  • On a Unity Forum Post, Someone had the same issue and one forum member replied:

    There's no support for any specific keyboard layouts. The way it works is that keys are identified by physical location. The US keyboard layout is used just to give the keys names. So the "A" key is always the key to the right of the Caps Lock key regardless of what kind of character that key actually generates according to the current keyboard. This is what's leading to the stable WASD behavior your friend was seeing.

    You can bind by generated text character. In the control picker, you can find this under "By Character Mapped to Key".


    In short:

    The input system recognizes keys based on their physical location, this can be changed through the control picker, by selecting "By Character Mapped to Key" instead of "By location of Key (Using US Layout)".

    Another way through script is:

    <Keyboard>/#{w}
    

    For more info, refer to the post:

    https://forum.unity.com/threads/new-input-system-which-keyboard-layouts-are-supported.912074/