Keyboard Support | Package Manager UI website
docs.unity3d.com
    ////WIP
    

    Keyboard Support

    A keyboard is defined as a device with a set of keys defined by the Key enumeration.

    The location of individual keys is agnostic to keyboard layout meaning that, for example, the A key is always the key to the right of the Caps Lock key regardless of where the currently active language layout places the key that generates an A character (if the layout even has a key assigned to that character).

    To query which (if any) character is generated by given key, use the key's displayName property. The value of the property will change automatically when the keyboard layout is changed at the system level.

    Controls

    A given key can be retrieved from Keyboard using either one of the accessor properties (e.g. Keyboard.spaceKey) or using Keyboard's indexer and the Key enumeration (e.g. keyboard[Key.Space].

    Control Type Description
    enterKey
    tabKey
    backquoteKey
    semicolonKey
    commaKey
    periodKey
    slashKey
    backslashKey
    leftBracketKey
    rightBracketKey
    minusKey
    equalsKey
    aKey
    bKey
    cKey
    dKey
    eKey
    dKey
    eKey
    fKey
    kKey
    hKey
    iKey
    jKey
    kKey
    lKey
    mKey
    nKey
    oKey
    pKey
    qKey
    rKey
    sKey
    tKey
    uKey
    vKey
    wKey
    xKey
    yKey
    zKey
        public KeyControl digit1Key { get; private set; }
        public KeyControl digit2Key { get; private set; }
        public KeyControl digit3Key { get; private set; }
        public KeyControl digit4Key { get; private set; }
        public KeyControl digit5Key { get; private set; }
        public KeyControl digit6Key { get; private set; }
        public KeyControl digit7Key { get; private set; }
        public KeyControl digit8Key { get; private set; }
        public KeyControl digit9Key { get; private set; }
        public KeyControl digit0Key { get; private set; }
        public KeyControl leftShiftKey { get; private set; }
        public KeyControl rightShiftKey { get; private set; }
        public KeyControl leftAltKey { get; private set; }
        public KeyControl rightAltKey { get; private set; }
        public KeyControl leftCtrlKey { get; private set; }
        public KeyControl rightCtrlKey { get; private set; }
        public KeyControl leftMetaKey { get; private set; }
        public KeyControl rightMetaKey { get; private set; }
        public KeyControl leftWindowsKey { get; private set; }
        public KeyControl rightWindowsKey { get; private set; }
        public KeyControl leftAppleKey { get; private set; }
        public KeyControl rightAppleKey { get; private set; }
        public KeyControl leftCommandKey { get; private set; }
        public KeyControl rightCommandKey { get; private set; }
        public KeyControl contextMenuKey { get; private set; }
        public KeyControl escapeKey { get; private set; }
        public KeyControl leftArrowKey { get; private set; }
        public KeyControl rightArrowKey { get; private set; }
        public KeyControl upArrowKey { get; private set; }
        public KeyControl downArrowKey { get; private set; }
        public KeyControl backspaceKey { get; private set; }
        public KeyControl pageDownKey { get; private set; }
        public KeyControl pageUpKey { get; private set; }
        public KeyControl homeKey { get; private set; }
        public KeyControl endKey { get; private set; }
        public KeyControl insertKey { get; private set; }
        public KeyControl deleteKey { get; private set; }
        public KeyControl capsLockKey { get; private set; }
        public KeyControl scrollLockKey { get; private set; }
        public KeyControl numLockKey { get; private set; }
        public KeyControl printScreenKey { get; private set; }
        public KeyControl pauseKey { get; private set; }
        public KeyControl numpadEnterKey { get; private set; }
        public KeyControl numpadDivideKey { get; private set; }
        public KeyControl numpadMultiplyKey { get; private set; }
        public KeyControl numpadMinusKey { get; private set; }
        public KeyControl numpadPlusKey { get; private set; }
        public KeyControl numpadPeriodKey { get; private set; }
        public KeyControl numpadEqualsKey { get; private set; }
        public KeyControl numpad0Key { get; private set; }
        public KeyControl numpad1Key { get; private set; }
        public KeyControl numpad2Key { get; private set; }
        public KeyControl numpad3Key { get; private set; }
        public KeyControl numpad4Key { get; private set; }
        public KeyControl numpad5Key { get; private set; }
        public KeyControl numpad6Key { get; private set; }
        public KeyControl numpad7Key { get; private set; }
        public KeyControl numpad8Key { get; private set; }
        public KeyControl numpad9Key { get; private set; }
        public KeyControl f1Key { get; private set; }
        public KeyControl f2Key { get; private set; }
        public KeyControl f3Key { get; private set; }
        public KeyControl f4Key { get; private set; }
        public KeyControl f5Key { get; private set; }
        public KeyControl f6Key { get; private set; }
        public KeyControl f7Key { get; private set; }
        public KeyControl f8Key { get; private set; }
        public KeyControl f9Key { get; private set; }
        public KeyControl f10Key { get; private set; }
        public KeyControl f11Key { get; private set; }
        public KeyControl f12Key { get; private set; }
        public KeyControl oem1Key { get; private set; }
        public KeyControl oem2Key { get; private set; }
        public KeyControl oem3Key { get; private set; }
        public KeyControl oem4Key { get; private set; }
        public KeyControl oem5Key { get; private set; }
    

    |

    Text Input

    It is recommended to not manually translate text input from key presses by trying to trying to string together the characters corresponding to the keys. Instead, to listen to text input, hook into Keyboard.onTextInput. This will deliver character-by-character input as reported by the platform (including input from on-screen keyboards).

    Note that the text input API does not allocate GC memory as it does not deliver fully composed strings.

    Keyboard Layouts

    The name of the current keyboard layout can be queried with Keyboard.keyboardLayout. Note that the names are platform-specific.

    There is no support for setting keyboard layouts from the application.

    To monitor for when the keyboard layout changes, hook into InputSystem.onDeviceChange and check for InputDeviceChange.ConfigurationChanged on a Keyboard device.

    IME

    On-Screen Keyboards

    We do not yet support on-screen keyboards in the new input system.
    For now, please Unity's existing API in `UnityEngine.TouchScreenKeyboard.
    
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023