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 |