image/svg+xml
docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
    Show / Hide Table of Contents
    • Unity​Engine.​Input​System
      • Accelerometer
      • Ambient​Temperature​Sensor
      • Attitude​Sensor
      • Common​Usages
      • Default​Input​Actions
      • Default​Input​Actions.​IPlayer​Actions
      • Default​Input​Actions.​IUIActions
      • Default​Input​Actions.​Player​Actions
      • Default​Input​Actions.​UIActions
      • Gamepad
      • Gravity​Sensor
      • Gyroscope
      • Humidity​Sensor
      • IInput​Action​Collection
      • IInput​Action​Collection2
      • IInput​Interaction
      • IInput​Interaction<TValue>
      • Input​Action
      • Input​Action.​Callback​Context
      • Input​Action​Asset
      • Input​Action​Change
      • Input​Action​Map
      • Input​Action​Phase
      • Input​Action​Property
      • Input​Action​Rebinding​Extensions
      • Input​Action​Rebinding​Extensions.​Rebinding​Operation
      • Input​Action​Reference
      • Input​Action​Setup​Extensions
      • Input​Action​Setup​Extensions.​Binding​Syntax
      • Input​Action​Setup​Extensions.​Composite​Syntax
      • Input​Action​Setup​Extensions.​Control​Scheme​Syntax
      • Input​Action​Type
      • Input​Binding
      • Input​Binding.​Display​String​Options
      • Input​Binding​Composite
      • Input​Binding​Composite<TValue>
      • Input​Binding​Composite​Context
      • Input​Binding​Composite​Context.​Part​Binding
      • Input​Control
      • Input​Control<TValue>
      • Input​Control​Extensions
      • Input​Control​Extensions.​Enumerate
      • Input​Control​Extensions.​Input​Event​Control​Collection
      • Input​Control​Extensions.​Input​Event​Control​Enumerator
      • Input​Control​Layout​Change
      • Input​Control​List<TControl>
      • Input​Control​Path
      • Input​Control​Path.​Human​Readable​String​Options
      • Input​Control​Path.​Parsed​Path​Component
      • Input​Control​Scheme
      • Input​Control​Scheme.​Device​Requirement
      • Input​Control​Scheme.​Match​Result
      • Input​Control​Scheme.​Match​Result.​Match
      • Input​Device
      • Input​Device​Change
      • Input​Extensions
      • Input​Interaction​Context
      • Input​Processor
      • Input​Processor<TValue>
      • Input​Recorder
      • Input​Recorder.​Change
      • Input​Recorder.​Change​Event
      • Input​Remoting
      • Input​Remoting.​Message
      • Input​Remoting.​Message​Type
      • Input​Settings
      • Input​Settings.​Background​Behavior
      • Input​Settings.​Editor​Input​Behavior​In​Play​Mode
      • Input​Settings.​iOSSettings
      • Input​Settings.​Update​Mode
      • Input​System
      • Input​Test​Fixture
      • Input​Test​Fixture.​Action​Constraint
      • Input​Value
      • Joystick
      • Key
      • Keyboard
      • Light​Sensor
      • Linear​Acceleration​Sensor
      • Magnetic​Field​Sensor
      • Mouse
      • Pen
      • Pen​Button
      • Player​Input
      • Player​Input.​Action​Event
      • Player​Input.​Controls​Changed​Event
      • Player​Input.​Device​Lost​Event
      • Player​Input.​Device​Regained​Event
      • Player​Input​Manager
      • Player​Input​Manager.​Player​Joined​Event
      • Player​Input​Manager.​Player​Left​Event
      • Player​Join​Behavior
      • Player​Notifications
      • Pointer
      • Pressure​Sensor
      • Proximity​Sensor
      • Sensor
      • Step​Counter
      • Touch​Phase
      • Touchscreen
      • Tracked​Device
    • Unity​Engine.​Input​System.​Android
      • Android​Accelerometer
      • Android​Ambient​Temperature
      • Android​Gamepad
      • Android​Gamepad​With​Dpad​Axes
      • Android​Gamepad​With​Dpad​Buttons
      • Android​Gravity​Sensor
      • Android​Gyroscope
      • Android​Joystick
      • Android​Light​Sensor
      • Android​Linear​Acceleration​Sensor
      • Android​Magnetic​Field​Sensor
      • Android​Pressure​Sensor
      • Android​Proximity
      • Android​Relative​Humidity
      • Android​Rotation​Vector
      • Android​Step​Counter
      • Dual​Shock4Gamepad​Android
      • Xbox​One​Gamepad​Android
    • Unity​Engine.​Input​System.​Composites
      • Axis​Composite
      • Axis​Composite.​Which​Side​Wins
      • Button​With​One​Modifier
      • Button​With​Two​Modifiers
      • One​Modifier​Composite
      • Two​Modifiers​Composite
      • Vector2Composite
      • Vector2Composite.​Mode
      • Vector3Composite
      • Vector3Composite.​Mode
    • Unity​Engine.​Input​System.​Controls
      • Any​Key​Control
      • Axis​Control
      • Axis​Control.​Clamp
      • Button​Control
      • Discrete​Button​Control
      • Double​Control
      • Dpad​Control
      • Dpad​Control.​Dpad​Axis​Control
      • Integer​Control
      • Key​Control
      • Quaternion​Control
      • Stick​Control
      • Touch​Control
      • Touch​Phase​Control
      • Touch​Press​Control
      • Vector2Control
      • Vector3Control
    • Unity​Engine.​Input​System.​Dual​Shock
      • Dual​Shock3Gamepad​HID
      • Dual​Shock4Gamepad​HID
      • Dual​Shock​Gamepad
      • IDual​Shock​Haptics
    • Unity​Engine.​Input​System.​Editor
      • Input​Control​Path​Editor
      • Input​Control​Picker
      • Input​Control​Picker.​Mode
      • Input​Control​Picker​State
      • Input​Parameter​Editor
      • Input​Parameter​Editor<TObject>
    • Unity​Engine.​Input​System.​Enhanced​Touch
      • Enhanced​Touch​Support
      • Finger
      • Touch
      • Touch​History
      • Touch​Simulation
    • Unity​Engine.​Input​System.​Haptics
      • IDual​Motor​Rumble
      • IHaptics
    • Unity​Engine.​Input​System.​HID
      • HID
      • HID.​Button
      • HID.​Generic​Desktop
      • HID.​HIDCollection​Descriptor
      • HID.​HIDCollection​Type
      • HID.​HIDDevice​Descriptor
      • HID.​HIDDevice​Descriptor​Builder
      • HID.​HIDElement​Descriptor
      • HID.​HIDElement​Flags
      • HID.​HIDReport​Type
      • HID.​Simulation
      • HID.​Usage​Page
      • HIDSupport
      • HIDSupport.​HIDPage​Usage
    • Unity​Engine.​Input​System.​Interactions
      • Hold​Interaction
      • Multi​Tap​Interaction
      • Press​Behavior
      • Press​Interaction
      • Slow​Tap​Interaction
      • Tap​Interaction
    • Unity​Engine.​Input​System.​iOS
      • Dual​Shock4Gampadi​OS
      • i​OSGame​Controller
      • Privacy​Data​Usage
      • Xbox​One​Gampadi​OS
    • Unity​Engine.​Input​System.​iOS.​Low​Level
      • i​OSStep​Counter
      • Motion​Authorization​Status
    • Unity​Engine.​Input​System.​Layouts
      • Input​Control​Attribute
      • Input​Control​Layout
      • Input​Control​Layout.​Builder
      • Input​Control​Layout.​Builder.​Control​Builder
      • Input​Control​Layout.​Control​Item
      • Input​Control​Layout.​Layout​Not​Found​Exception
      • Input​Control​Layout​Attribute
      • Input​Device​Description
      • Input​Device​Find​Control​Layout​Delegate
      • Input​Device​Matcher
    • Unity​Engine.​Input​System.​Low​Level
      • Delta​State​Event
      • Device​Configuration​Event
      • Device​Remove​Event
      • Device​Reset​Event
      • Disable​Device​Command
      • Enable​Device​Command
      • Enable​IMEComposition​Command
      • Gamepad​Button
      • Gamepad​State
      • IInput​Device​Command​Info
      • IInput​Event​Type​Info
      • IInput​State​Callback​Receiver
      • IInput​State​Change​Monitor
      • IInput​State​Type​Info
      • IInput​Update​Callback​Receiver
      • IMEComposition​Event
      • IMEComposition​String
      • Initiate​User​Account​Pairing​Command
      • Initiate​User​Account​Pairing​Command.​Result
      • Input​Device​Command
      • Input​Device​Command​Delegate
      • Input​Device​Execute​Command​Delegate
      • Input​Event
      • Input​Event​Buffer
      • Input​Event​Listener
      • Input​Event​Ptr
      • Input​Event​Trace
      • Input​Event​Trace.​Device​Info
      • Input​Event​Trace.​Replay​Controller
      • Input​Metrics
      • Input​State
      • Input​State​Block
      • Input​State​History
      • Input​State​History.​Record
      • Input​State​History.​Record​Header
      • Input​State​History<TValue>
      • Input​State​History<TValue>.​Record
      • Input​Update​Type
      • IText​Input​Receiver
      • Keyboard​State
      • Mouse​Button
      • Mouse​State
      • Pen​State
      • Query​Can​Run​In​Background
      • Query​Dimensions​Command
      • Query​Enabled​State​Command
      • Query​Keyboard​Layout​Command
      • Query​Key​Name​Command
      • Query​Paired​User​Account​Command
      • Query​Paired​User​Account​Command.​Result
      • Request​Reset​Command
      • Request​Sync​Command
      • Set​IMECursor​Position​Command
      • Set​Sampling​Frequency​Command
      • State​Event
      • Text​Event
      • Touch​State
    • Unity​Engine.​Input​System.​On​Screen
      • On​Screen​Button
      • On​Screen​Control
      • On​Screen​Stick
    • Unity​Engine.​Input​System.​Processors
      • Axis​Deadzone​Processor
      • Clamp​Processor
      • Editor​Window​Space​Processor
      • Invert​Processor
      • Invert​Vector2Processor
      • Invert​Vector3Processor
      • Normalize​Processor
      • Normalize​Vector2Processor
      • Normalize​Vector3Processor
      • Scale​Processor
      • Scale​Vector2Processor
      • Scale​Vector3Processor
      • Stick​Deadzone​Processor
    • Unity​Engine.​Input​System.​Samples
      • Input​Action​Visualizer
      • Input​Action​Visualizer.​Visualization
      • Input​Control​Visualizer
      • Input​Control​Visualizer.​Mode
      • Input​Visualizer
    • Unity​Engine.​Input​System.​Switch
      • Switch​Pro​Controller​HID
    • Unity​Engine.​Input​System.​UI
      • Extended​Pointer​Event​Data
      • Input​System​UIInput​Module
      • Multiplayer​Event​System
      • Tracked​Device​Raycaster
      • UIPointer​Behavior
      • UIPointer​Type
      • Virtual​Mouse​Input
      • Virtual​Mouse​Input.​Cursor​Mode
    • Unity​Engine.​Input​System.​Users
      • Input​User
      • Input​User.​Control​Scheme​Change​Syntax
      • Input​User​Account​Handle
      • Input​User​Change
      • Input​User​Pairing​Options
    • Unity​Engine.​Input​System.​Utilities
      • Display​String​Format​Attribute
      • Four​CC
      • Input​Action​Trace
      • Input​Action​Trace.​Action​Event​Ptr
      • Interned​String
      • Name​And​Parameters
      • Named​Value
      • Observable
      • Primitive​Value
      • Read​Only​Array<TValue>
      • Read​Only​Array<TValue>.​Enumerator
      • Read​Only​Array​Extensions
      • Vector2Magnitude​Comparer
      • Vector3Magnitude​Comparer
    • Unity​Engine.​Input​System.​Web​GL
      • Web​GLGamepad
      • Web​GLJoystick
    • Unity​Engine.​Input​System.​XInput
      • IXbox​One​Rumble
      • Xbox​Gamepad​Mac​OS
      • Xbox​One​Gampad​Mac​OSWireless
      • XInput​Controller
      • XInput​Controller.​Device​Flags
      • XInput​Controller.​Device​Sub​Type
    • Unity​Engine.​Input​System.​XR
      • Bone
      • Bone​Control
      • Eyes
      • Eyes​Control
      • Feature​Type
      • Pose​Control
      • Pose​State
      • Tracked​Pose​Driver
      • Tracked​Pose​Driver.​Tracking​Type
      • Tracked​Pose​Driver.​Update​Type
      • Usage​Hint
      • XRController
      • XRController​With​Rumble
      • XRDevice​Descriptor
      • XRFeature​Descriptor
      • XRHMD
      • XRUtilities
    • Unity​Engine.​Input​System.​XR.​Haptics
      • Buffered​Rumble
      • Get​Current​Haptic​State​Command
      • Get​Haptic​Capabilities​Command
      • Haptic​Capabilities
      • Haptic​State
      • Send​Buffered​Haptic​Command
      • Send​Haptic​Impulse​Command
    • Scripting API
    • Unity​Engine.​Input​System
    • Key

    Enum Key

    Enumeration of key codes.

    Namespace: UnityEngine.InputSystem
    Syntax
    public enum Key : int
    Remarks

    Named according to the US keyboard layout which is used as a reference layout. Note, however, that keys are identified by physical location, not by the characters they generate. This means, for example, that A is always the key to the right of CapsLock, regardless of which key (if any) produces the "a" character on the current keyboard layout.

    To find the text character (if any) generated by a key according to the currently active keyboard layout, use the displayName property of KeyControl.

    // Look up key by key code.
    var aKey = Keyboard.current[Key.A];
    
    // Find out which text is produced by the key.
    Debug.Log($"The '{aKey.keyCode}' key produces '{aKey.displayName}' as text input");

    Fields

    Name Description Value
    None

    Invalid key. Does not represent a key on the keyboard and is only used to have a default for the Key enumeration not represent any specific key.

    0
    OEM2

    The oem2Key.

    OEM1

    The oem1Key.

    NumpadPlus

    The numpadPlusKey.

    NumpadPeriod

    The numpadPeriodKey.

    NumpadMultiply

    The numpadMultiplyKey.

    NumpadMinus

    The numpadMinusKey.

    NumpadEquals

    The numpadEqualsKey.

    NumpadEnter

    The numpadEnterKey.

    G

    The gKey.

    21
    H

    The hKey.

    22
    NumpadDivide

    The numpadDivideKey.

    I

    The iKey.

    23
    Numpad9

    The numpad9Key.

    Numpad8

    The numpad8Key.

    J

    The jKey.

    24
    K

    The kKey.

    25
    L

    The lKey.

    26
    Numpad7

    The numpad7Key.

    Numpad6

    The numpad6Key.

    Numpad5

    The numpad5Key.

    LeftBracket

    The leftBracketKey.

    11
    Numpad4

    The numpad4Key.

    Numpad3

    The numpad3Key.

    Numpad2

    The numpad2Key.

    Numpad1

    The numpad1Key.

    Numpad0

    The numpad0Key.

    NumLock

    The numLockKey.

    OEM3

    The oem3Key.

    OEM4

    The oem4Key.

    OEM5

    The oem5Key.

    PageDown

    The pageDownKey.

    UpArrow

    The upArrowKey.

    Space

    The spaceKey.

    1
    Tab

    The tabKey.

    3
    Backquote

    The backquoteKey.

    4
    Semicolon

    The semicolonKey.

    6
    Comma

    The commaKey.

    7
    Slash

    The slashKey.

    9
    Backslash

    The backslashKey.

    10
    B

    The bKey.

    16
    C

    The cKey.

    17
    D

    The dKey.

    18
    ScrollLock

    The scrollLockKey.

    RightWindows

    Same as RightMeta.

    Minus

    The minusKey.

    13
    RightMeta

    The rightMetaKey.

    RightCommand

    Same as RightMeta.

    RightBracket

    The rightBracketKey.

    12
    RightArrow

    The rightArrowKey.

    RightApple

    Same as RightMeta.

    Quote

    The quoteKey.

    5
    PrintScreen

    The printScreenKey.

    Period

    The periodKey.

    8
    E

    The eKey.

    19
    Pause

    The pauseKey.

    Enter

    The enterKey.

    2
    Equals

    The equalsKey.

    14
    PageUp

    The pageUpKey.

    F

    The fKey.

    20
    RightCtrl

    The rightCtrlKey.

    A

    The aKey.

    15
    M

    The mKey.

    27
    Q

    The qKey.

    31
    R

    The rKey.

    32
    S

    The sKey.

    33
    T

    The tKey.

    34
    U

    The uKey.

    35
    V

    The vKey.

    36
    W

    The wKey.

    37
    X

    The xKey.

    38
    Y

    The yKey.

    39
    Delete

    The deleteKey.

    Digit1

    The digit1Key.

    41
    Digit0

    The digit0Key.

    50
    CapsLock

    The capsLockKey.

    Digit2

    The digit2Key.

    42
    Digit3

    The digit3Key.

    43
    Digit4

    The digit4Key.

    44
    Digit5

    The digit5Key.

    45
    Digit6

    The digit6Key.

    46
    Digit7

    The digit7Key.

    47
    Digit9

    The digit9Key.

    49
    RightShift

    The rightShiftKey.

    52
    RightAlt

    The rightAltKey.

    54
    Backspace

    The backspaceKey.

    Digit8

    The digit8Key.

    48
    AltGr

    Same as RightAlt.

    ContextMenu

    The contextMenuKey.

    DownArrow

    The downArrowKey.

    End

    The endKey.

    Escape

    The escapeKey.

    LeftWindows

    Same as LeftMeta.

    LeftShift

    The leftShiftKey.

    51
    LeftMeta

    The leftMetaKey.

    LeftCtrl

    The leftCtrlKey.

    LeftCommand

    Same as LeftMeta.

    LeftArrow

    The leftArrowKey.

    LeftApple

    Same as LeftMeta.

    LeftAlt

    The leftAltKey.

    53
    Insert

    The insertKey.

    IMESelected
    Home

    The homeKey.

    F9

    The f9Key.

    F8

    The f8Key.

    F7

    The f7Key.

    F6

    The f6Key.

    F5

    The f5Key.

    F4

    The f4Key.

    O

    The oKey.

    29
    F3

    The f3Key.

    F2

    The f2Key.

    F12

    The f12Key.

    F11

    The f11Key.

    F10

    The f10Key.

    P

    The pKey.

    30
    F1

    The f1Key.

    N

    The nKey.

    28
    Z

    The zKey.

    40

    Extension Methods

    InputExtensions.IsModifierKey()
    InputExtensions.IsTextInputKey()
    In This Article
    • Fields
    • Extension Methods
    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