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.

KeyCodeKeyCode
Backspace8 Print Screennone
Tab9 Insert45
Enter 13Delete46
Shift 16Windows Left 91
Control17Windows Right92
Alt 18Select93
Break19Multiply106
Caps Lock20Add 107
Escape27Separator109
Space Bar32Subtract109
Page Up33Decimal Point110
Page Down 34Divide111
End 35Num Lock144
Home36Scroll Lock145
Left Arrow37
Up Arrow38
Right Arrow39
Down Arrow40