Class Keyboard | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class Keyboard

    A keyboard input device.

    Inheritance
    System.Object
    InputControl
    InputDevice
    Keyboard
    Inherited Members
    InputDevice.kInvalidDeviceId
    InputDevice.description
    InputDevice.enabled
    InputDevice.canRunInBackground
    InputDevice.added
    InputDevice.remote
    InputDevice.native
    InputDevice.updateBeforeRender
    InputDevice.id
    InputDevice.lastUpdateTime
    InputDevice.wasUpdatedThisFrame
    InputDevice.allControls
    InputDevice.valueType
    InputDevice.valueSizeInBytes
    InputDevice.ReadValueFromStateAsObject(Void*)
    InputDevice.ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
    InputDevice.CompareValue(Void*, Void*)
    InputDevice.OnAdded()
    InputDevice.ExecuteCommand<TCommand>(TCommand)
    InputControl.ReservedCharacters
    InputControl.name
    InputControl.displayName
    InputControl.shortDisplayName
    InputControl.path
    InputControl.layout
    InputControl.variants
    InputControl.device
    InputControl.parent
    InputControl.children
    InputControl.usages
    InputControl.aliases
    InputControl.stateBlock
    InputControl.noisy
    InputControl.synthetic
    InputControl.Item[String]
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.EvaluateMagnitude(Void*)
    InputControl.WriteValueFromBufferIntoState(Void*, Int32, Void*)
    InputControl.WriteValueFromObjectIntoState(Object, Void*)
    InputControl.CompareState(Void*, Void*, Void*)
    InputControl.TryGetChildControl(String)
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UnityEngine.Experimental.Input
    Syntax
    public class Keyboard : InputDevice, ITextInputReceiver
    Remarks

    Keyboards allow for both individual button input as well as text input.

    Be aware that identification of keys in the system is layout-agnostic. For example, the key referred to as the "a" key is always the key to the right of Caps Lock regardless of where the current keyboard layout actually puts the "a" character (if it even has any). To find what is actually behind a key according to the current keyboard layout, use displayName, , and .

    Fields

    KeyCount

    Declaration
    public const int KeyCount = 110
    Field Value
    Type Description
    System.Int32

    Properties

    aKey

    The 'a' key. Key immediately to the right of the caps lock key.

    Declaration
    public KeyControl aKey { get; }
    Property Value
    Type Description
    KeyControl

    anyKey

    A synthetic button control that is considered pressed if any key on the keyboard is pressed.

    Declaration
    public AnyKeyControl anyKey { get; }
    Property Value
    Type Description
    AnyKeyControl

    backquoteKey

    The ` key. The leftmost key in the row of digits. Directly above tab.

    Declaration
    public KeyControl backquoteKey { get; }
    Property Value
    Type Description
    KeyControl

    backslashKey

    Declaration
    public KeyControl backslashKey { get; }
    Property Value
    Type Description
    KeyControl

    backspaceKey

    Declaration
    public KeyControl backspaceKey { get; }
    Property Value
    Type Description
    KeyControl

    bKey

    Declaration
    public KeyControl bKey { get; }
    Property Value
    Type Description
    KeyControl

    capsLockKey

    Declaration
    public KeyControl capsLockKey { get; }
    Property Value
    Type Description
    KeyControl

    cKey

    Declaration
    public KeyControl cKey { get; }
    Property Value
    Type Description
    KeyControl

    commaKey

    The ',' key. Third key to the left of the right shift key.

    Declaration
    public KeyControl commaKey { get; }
    Property Value
    Type Description
    KeyControl

    contextMenuKey

    Declaration
    public KeyControl contextMenuKey { get; }
    Property Value
    Type Description
    KeyControl

    current

    Declaration
    public static Keyboard current { get; }
    Property Value
    Type Description
    Keyboard

    deleteKey

    Declaration
    public KeyControl deleteKey { get; }
    Property Value
    Type Description
    KeyControl

    digit0Key

    Declaration
    public KeyControl digit0Key { get; }
    Property Value
    Type Description
    KeyControl

    digit1Key

    Declaration
    public KeyControl digit1Key { get; }
    Property Value
    Type Description
    KeyControl

    digit2Key

    Declaration
    public KeyControl digit2Key { get; }
    Property Value
    Type Description
    KeyControl

    digit3Key

    Declaration
    public KeyControl digit3Key { get; }
    Property Value
    Type Description
    KeyControl

    digit4Key

    Declaration
    public KeyControl digit4Key { get; }
    Property Value
    Type Description
    KeyControl

    digit5Key

    Declaration
    public KeyControl digit5Key { get; }
    Property Value
    Type Description
    KeyControl

    digit6Key

    Declaration
    public KeyControl digit6Key { get; }
    Property Value
    Type Description
    KeyControl

    digit7Key

    Declaration
    public KeyControl digit7Key { get; }
    Property Value
    Type Description
    KeyControl

    digit8Key

    Declaration
    public KeyControl digit8Key { get; }
    Property Value
    Type Description
    KeyControl

    digit9Key

    Declaration
    public KeyControl digit9Key { get; }
    Property Value
    Type Description
    KeyControl

    dKey

    Declaration
    public KeyControl dKey { get; }
    Property Value
    Type Description
    KeyControl

    downArrowKey

    Declaration
    public KeyControl downArrowKey { get; }
    Property Value
    Type Description
    KeyControl

    eKey

    Declaration
    public KeyControl eKey { get; }
    Property Value
    Type Description
    KeyControl

    endKey

    Declaration
    public KeyControl endKey { get; }
    Property Value
    Type Description
    KeyControl

    enterKey

    The enter/return key in the main key block.

    Declaration
    public KeyControl enterKey { get; }
    Property Value
    Type Description
    KeyControl
    Remarks

    This key is distinct from the enter key on the numpad which is numpadEnterKey.

    equalsKey

    The '=' key in the main key block. Key immediately to the left of the backspace key.

    Declaration
    public KeyControl equalsKey { get; }
    Property Value
    Type Description
    KeyControl

    escapeKey

    Declaration
    public KeyControl escapeKey { get; }
    Property Value
    Type Description
    KeyControl

    f10Key

    Declaration
    public KeyControl f10Key { get; }
    Property Value
    Type Description
    KeyControl

    f11Key

    Declaration
    public KeyControl f11Key { get; }
    Property Value
    Type Description
    KeyControl

    f12Key

    Declaration
    public KeyControl f12Key { get; }
    Property Value
    Type Description
    KeyControl

    f1Key

    Declaration
    public KeyControl f1Key { get; }
    Property Value
    Type Description
    KeyControl

    f2Key

    Declaration
    public KeyControl f2Key { get; }
    Property Value
    Type Description
    KeyControl

    f3Key

    Declaration
    public KeyControl f3Key { get; }
    Property Value
    Type Description
    KeyControl

    f4Key

    Declaration
    public KeyControl f4Key { get; }
    Property Value
    Type Description
    KeyControl

    f5Key

    Declaration
    public KeyControl f5Key { get; }
    Property Value
    Type Description
    KeyControl

    f6Key

    Declaration
    public KeyControl f6Key { get; }
    Property Value
    Type Description
    KeyControl

    f7Key

    Declaration
    public KeyControl f7Key { get; }
    Property Value
    Type Description
    KeyControl

    f8Key

    Declaration
    public KeyControl f8Key { get; }
    Property Value
    Type Description
    KeyControl

    f9Key

    Declaration
    public KeyControl f9Key { get; }
    Property Value
    Type Description
    KeyControl

    fKey

    Declaration
    public KeyControl fKey { get; }
    Property Value
    Type Description
    KeyControl

    gKey

    Declaration
    public KeyControl gKey { get; }
    Property Value
    Type Description
    KeyControl

    hKey

    Declaration
    public KeyControl hKey { get; }
    Property Value
    Type Description
    KeyControl

    homeKey

    Declaration
    public KeyControl homeKey { get; }
    Property Value
    Type Description
    KeyControl

    iKey

    Declaration
    public KeyControl iKey { get; }
    Property Value
    Type Description
    KeyControl

    imeCursorPosition

    Sets the cursor position for IME composition dialogs. Units are from the upper left, in pixels, moving down and to the right.

    Declaration
    public Vector2 imeCursorPosition { set; }
    Property Value
    Type Description
    Vector2
    Remarks

    Some languages use complex input methods which involve opening windows to insert characters. Typically, this is not desirable while playing a game, as games may just interpret key strokes as game input, not as text.

    See imeEnabled for turning IME on/off

    imeEnabled

    Activates/deactivates IME composition while typing. This decides whether or not to use the OS supplied IME system.

    Declaration
    public bool imeEnabled { set; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    Some languages use complex input methods which involve opening windows to insert characters. Typically, this is not desirable while playing a game, as games may just interpret key strokes as game input, not as text. Setting this to On, will enable the OS-level IME system when the user presses keystrokes.

    See imeCursorPosition, onIMECompositionChange, imeSelected for more IME settings and data.

    imeSelected

    True when IME composition is enabled. Requires imeEnabled to be set to true, and the user to enable it at the OS level.

    Declaration
    public ButtonControl imeSelected { get; }
    Property Value
    Type Description
    ButtonControl
    Remarks

    Some languages use complex input methods which involve opening windows to insert characters. Typically, this is not desirable while playing a game, as games may just interpret key strokes as game input, not as text.

    See imeEnabled for turning IME on/off

    insertKey

    Declaration
    public KeyControl insertKey { get; }
    Property Value
    Type Description
    KeyControl

    Item[Key]

    Look up a key control by its key code.

    Declaration
    public KeyControl this[Key key] { get; }
    Parameters
    Type Name Description
    Key key
    Property Value
    Type Description
    KeyControl

    jKey

    Declaration
    public KeyControl jKey { get; }
    Property Value
    Type Description
    KeyControl

    keyboardLayout

    The name of the layout currently used by the keyboard.

    Declaration
    public string keyboardLayout { get; protected set; }
    Property Value
    Type Description
    System.String
    Remarks

    Note that keyboard layout names are platform-specific.

    The value of this property reflects the currently used layout and thus changes whenever the layout of the system or the one for the application is changed.

    To determine what a key represents in the current layout, use displayName, , and .

    kKey

    Declaration
    public KeyControl kKey { get; }
    Property Value
    Type Description
    KeyControl

    leftAltKey

    Declaration
    public KeyControl leftAltKey { get; }
    Property Value
    Type Description
    KeyControl

    leftAppleKey

    Declaration
    public KeyControl leftAppleKey { get; }
    Property Value
    Type Description
    KeyControl

    leftArrowKey

    Declaration
    public KeyControl leftArrowKey { get; }
    Property Value
    Type Description
    KeyControl

    leftBracketKey

    Declaration
    public KeyControl leftBracketKey { get; }
    Property Value
    Type Description
    KeyControl

    leftCommandKey

    Declaration
    public KeyControl leftCommandKey { get; }
    Property Value
    Type Description
    KeyControl

    leftCtrlKey

    Declaration
    public KeyControl leftCtrlKey { get; }
    Property Value
    Type Description
    KeyControl

    leftMetaKey

    Declaration
    public KeyControl leftMetaKey { get; }
    Property Value
    Type Description
    KeyControl

    leftShiftKey

    Declaration
    public KeyControl leftShiftKey { get; }
    Property Value
    Type Description
    KeyControl

    leftWindowsKey

    Declaration
    public KeyControl leftWindowsKey { get; }
    Property Value
    Type Description
    KeyControl

    lKey

    Declaration
    public KeyControl lKey { get; }
    Property Value
    Type Description
    KeyControl

    minusKey

    Declaration
    public KeyControl minusKey { get; }
    Property Value
    Type Description
    KeyControl

    mKey

    Declaration
    public KeyControl mKey { get; }
    Property Value
    Type Description
    KeyControl

    nKey

    Declaration
    public KeyControl nKey { get; }
    Property Value
    Type Description
    KeyControl

    numLockKey

    Declaration
    public KeyControl numLockKey { get; }
    Property Value
    Type Description
    KeyControl

    numpad0Key

    Declaration
    public KeyControl numpad0Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad1Key

    Declaration
    public KeyControl numpad1Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad2Key

    Declaration
    public KeyControl numpad2Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad3Key

    Declaration
    public KeyControl numpad3Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad4Key

    Declaration
    public KeyControl numpad4Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad5Key

    Declaration
    public KeyControl numpad5Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad6Key

    Declaration
    public KeyControl numpad6Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad7Key

    Declaration
    public KeyControl numpad7Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad8Key

    Declaration
    public KeyControl numpad8Key { get; }
    Property Value
    Type Description
    KeyControl

    numpad9Key

    Declaration
    public KeyControl numpad9Key { get; }
    Property Value
    Type Description
    KeyControl

    numpadDivideKey

    Declaration
    public KeyControl numpadDivideKey { get; }
    Property Value
    Type Description
    KeyControl

    numpadEnterKey

    Declaration
    public KeyControl numpadEnterKey { get; }
    Property Value
    Type Description
    KeyControl

    numpadEqualsKey

    Declaration
    public KeyControl numpadEqualsKey { get; }
    Property Value
    Type Description
    KeyControl

    numpadMinusKey

    Declaration
    public KeyControl numpadMinusKey { get; }
    Property Value
    Type Description
    KeyControl

    numpadMultiplyKey

    Declaration
    public KeyControl numpadMultiplyKey { get; }
    Property Value
    Type Description
    KeyControl

    numpadPeriodKey

    Declaration
    public KeyControl numpadPeriodKey { get; }
    Property Value
    Type Description
    KeyControl

    numpadPlusKey

    Declaration
    public KeyControl numpadPlusKey { get; }
    Property Value
    Type Description
    KeyControl

    oem1Key

    Declaration
    public KeyControl oem1Key { get; }
    Property Value
    Type Description
    KeyControl

    oem2Key

    Declaration
    public KeyControl oem2Key { get; }
    Property Value
    Type Description
    KeyControl

    oem3Key

    Declaration
    public KeyControl oem3Key { get; }
    Property Value
    Type Description
    KeyControl

    oem4Key

    Declaration
    public KeyControl oem4Key { get; }
    Property Value
    Type Description
    KeyControl

    oem5Key

    Declaration
    public KeyControl oem5Key { get; }
    Property Value
    Type Description
    KeyControl

    oKey

    Declaration
    public KeyControl oKey { get; }
    Property Value
    Type Description
    KeyControl

    pageDownKey

    Declaration
    public KeyControl pageDownKey { get; }
    Property Value
    Type Description
    KeyControl

    pageUpKey

    Declaration
    public KeyControl pageUpKey { get; }
    Property Value
    Type Description
    KeyControl

    pauseKey

    Declaration
    public KeyControl pauseKey { get; }
    Property Value
    Type Description
    KeyControl

    periodKey

    Declaration
    public KeyControl periodKey { get; }
    Property Value
    Type Description
    KeyControl

    pKey

    Declaration
    public KeyControl pKey { get; }
    Property Value
    Type Description
    KeyControl

    printScreenKey

    Declaration
    public KeyControl printScreenKey { get; }
    Property Value
    Type Description
    KeyControl

    qKey

    Declaration
    public KeyControl qKey { get; }
    Property Value
    Type Description
    KeyControl

    quoteKey

    The ' key. The key immediately to the left of the enter/return key.

    Declaration
    public KeyControl quoteKey { get; }
    Property Value
    Type Description
    KeyControl

    rightAltKey

    Declaration
    public KeyControl rightAltKey { get; }
    Property Value
    Type Description
    KeyControl

    rightAppleKey

    Declaration
    public KeyControl rightAppleKey { get; }
    Property Value
    Type Description
    KeyControl

    rightArrowKey

    Declaration
    public KeyControl rightArrowKey { get; }
    Property Value
    Type Description
    KeyControl

    rightBracketKey

    Declaration
    public KeyControl rightBracketKey { get; }
    Property Value
    Type Description
    KeyControl

    rightCommandKey

    Declaration
    public KeyControl rightCommandKey { get; }
    Property Value
    Type Description
    KeyControl

    rightCtrlKey

    Declaration
    public KeyControl rightCtrlKey { get; }
    Property Value
    Type Description
    KeyControl

    rightMetaKey

    Declaration
    public KeyControl rightMetaKey { get; }
    Property Value
    Type Description
    KeyControl

    rightShiftKey

    Declaration
    public KeyControl rightShiftKey { get; }
    Property Value
    Type Description
    KeyControl

    rightWindowsKey

    Declaration
    public KeyControl rightWindowsKey { get; }
    Property Value
    Type Description
    KeyControl

    rKey

    Declaration
    public KeyControl rKey { get; }
    Property Value
    Type Description
    KeyControl

    scrollLockKey

    Declaration
    public KeyControl scrollLockKey { get; }
    Property Value
    Type Description
    KeyControl

    semicolonKey

    The ';' key. The key immediately to the left of the quote key.

    Declaration
    public KeyControl semicolonKey { get; }
    Property Value
    Type Description
    KeyControl

    sKey

    Declaration
    public KeyControl sKey { get; }
    Property Value
    Type Description
    KeyControl

    slashKey

    Declaration
    public KeyControl slashKey { get; }
    Property Value
    Type Description
    KeyControl

    spaceKey

    The space bar key.

    Declaration
    public KeyControl spaceKey { get; }
    Property Value
    Type Description
    KeyControl

    tabKey

    The tab key.

    Declaration
    public KeyControl tabKey { get; }
    Property Value
    Type Description
    KeyControl

    tKey

    Declaration
    public KeyControl tKey { get; }
    Property Value
    Type Description
    KeyControl

    uKey

    Declaration
    public KeyControl uKey { get; }
    Property Value
    Type Description
    KeyControl

    upArrowKey

    Declaration
    public KeyControl upArrowKey { get; }
    Property Value
    Type Description
    KeyControl

    vKey

    Declaration
    public KeyControl vKey { get; }
    Property Value
    Type Description
    KeyControl

    wKey

    Declaration
    public KeyControl wKey { get; }
    Property Value
    Type Description
    KeyControl

    xKey

    Declaration
    public KeyControl xKey { get; }
    Property Value
    Type Description
    KeyControl

    yKey

    Declaration
    public KeyControl yKey { get; }
    Property Value
    Type Description
    KeyControl

    zKey

    Declaration
    public KeyControl zKey { get; }
    Property Value
    Type Description
    KeyControl

    Methods

    FinishSetup(InputDeviceBuilder)

    Declaration
    protected override void FinishSetup(InputDeviceBuilder builder)
    Parameters
    Type Name Description
    InputDeviceBuilder builder
    Overrides
    InputControl.FinishSetup(InputDeviceBuilder)

    MakeCurrent()

    Declaration
    public override void MakeCurrent()
    Overrides
    InputDevice.MakeCurrent()

    OnIMECompositionChanged(IMECompositionString)

    Declaration
    public void OnIMECompositionChanged(IMECompositionString compositionString)
    Parameters
    Type Name Description
    IMECompositionString compositionString
    Implements
    ITextInputReceiver.OnIMECompositionChanged(IMECompositionString)

    OnRemoved()

    Declaration
    protected override void OnRemoved()
    Overrides
    InputDevice.OnRemoved()

    OnTextInput(Char)

    Declaration
    public void OnTextInput(char character)
    Parameters
    Type Name Description
    System.Char character
    Implements
    ITextInputReceiver.OnTextInput(Char)

    RefreshConfiguration()

    Declaration
    protected override void RefreshConfiguration()
    Overrides
    InputControl.RefreshConfiguration()

    Events

    onIMECompositionChange

    An event that is fired to get IME composition strings. Fired once for every change, sends the entire string to date, and sends a blank string whenever a composition is submitted or reset.

    Declaration
    public event Action<IMECompositionString> onIMECompositionChange
    Event Type
    Type Description
    Action<IMECompositionString>
    Remarks

    Some languages use complex input methods which involve opening windows to insert characters. Typically, this is not desirable while playing a game, as games may just interpret key strokes as game input, not as text.

    See imeEnabled for turning IME on/off

    onTextInput

    Event that is fired for every single character entered on the keyboard.

    Declaration
    public event Action<char> onTextInput
    Event Type
    Type Description
    Action<System.Char>
    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