Javascript Key Codes

Javascript assigns a numeric code to every key on a keyboard, including ones that control programs and interfaces.

Alphanumeric Keys

Key codes for alphanumeric and function keys are consecutively numbered. Alphanumeric and symbol keys also have Unicode values, expressed as a negative number with Unicode decimal code.
  • The 0 to 9 keys are codes 48 to 57
  • The A to Z keys are codes 65 to 90
  • Keys on the number pad are codes 96 to 105
  • Function keys F1 to F12 are 112 to 123.
For program clarity it is better to use Unicode negative decimal codes than alphanumeric key codes.

Table of Key Codes

These are keys that control the user interface and operating system. Not all keys appear on all keyboards.
Key
Code
Key
Code
Backspace
8
Print Screen
none
Tab
9
Insert
45
Enter
13
Delete
46
Shift
16
Windows Left
91
Control
17
Windows Right
92
Alt
18
Select
93
Break
19
Multiply
106
Caps Lock
20
Add
107
Escape
27
Separator
109
Space Bar
32
Subtract
109
Page Up
33
Decimal Point
110
Page Down
34
Divide
111
End
35
Num Lock
144
Home
36
Scroll Lock
145
Left Arrow
37
Up Arrow
38
Right Arrow
39
Down Arrow
40