Home·Key codes
Ad

Claim your crypto exchange bonus

Bonuses you get just for signing up. Terms are copied straight from each exchange.

code and keyCode for 120 keys

The values a KeyboardEvent gives you. code is the physical position and never changes with layout; key is what actually gets typed, and that does.

code versus key

code is the physical position, the same on a Korean or French keyboard. key is what gets typed and changes — the same spot gives a, A or ㅁ. Use code to ask which spot was pressed, key to ask what was entered.

keyCode has been dropped from the standard. Write new code against code or key; the numbers here are for reading old code.

Letters26

The position is fixed as KeyA. Even when a Hangul ㅁ is typed, the code is still KeyA.

KeyA"a"65KeyB"b"66KeyC"c"67KeyD"d"68KeyE"e"69KeyF"f"70KeyG"g"71KeyH"h"72KeyI"i"73KeyJ"j"74KeyK"k"75KeyL"l"76KeyM"m"77KeyN"n"78KeyO"o"79KeyP"p"80KeyQ"q"81KeyR"r"82KeyS"s"83KeyT"t"84KeyU"u"85KeyV"v"86KeyW"w"87KeyX"x"88KeyY"y"89KeyZ"z"90

Digits10

The number row. Its keyCodes differ from the same digits on the numpad.

Digit0"0"48Digit1"1"49Digit2"2"50Digit3"3"51Digit4"4"52Digit5"5"53Digit6"6"54Digit7"7"55Digit8"8"56Digit9"9"57

Punctuation12

This is where keyCode values part ways between browsers.

Semicolon";"186Equal"="187Comma","188Minus"-"189Period"."190Slash"/"191Backquote"`"192BracketLeft"["219Backslash"\"220BracketRight"]"221Quote"'"222IntlBackslash"\"226

Numpad20

location is 3, which is what tells it apart from the number row.

Numpad0"0"96Numpad1"1"97Numpad2"2"98Numpad3"3"99Numpad4"4"100Numpad5"5"101Numpad6"6"102Numpad7"7"103Numpad8"8"104Numpad9"9"105NumpadAdd"+"107NumpadSubtract"-"109NumpadMultiply"*"106NumpadDivide"/"111NumpadDecimal"."110NumpadEnterEnter13NumpadEqual"="12NumpadComma","194NumpadParenLeft"("0NumpadParenRight")"0

Function keys24

F1 is 112, F2 is 113, and so on in order.

F1F1112F2F2113F3F3114F4F4115F5F5116F6F6117F7F7118F8F8119F9F9120F10F10121F11F11122F12F12123F13F13124F14F14125F15F15126F16F16127F17F17128F18F18129F19F19130F20F20131F21F21132F22F22133F23F23134F24F24135

Navigation8

They type nothing and only move the cursor.

ArrowUpArrowUp38ArrowDownArrowDown40ArrowLeftArrowLeft37ArrowRightArrowRight39HomeHome36EndEnd35PageUpPageUp33PageDownPageDown34

Editing16

Deleting, inserting, breaking a line.

EnterEnter13TabTab9Space"Space"32BackspaceBackspace8DeleteDelete46InsertInsert45UndoUndo0CutCut0CopyCopy0PastePaste0AgainAgain0FindFind0HelpHelp47SelectSelect41OpenOpen43PropsProps0

Modifiers9

They do nothing alone and ride on other keys. Left and right share one keyCode.

ShiftLeftShift16ShiftRightShift16ControlLeftControl17ControlRightControl17AltLeftAlt18AltRightAlt18MetaLeftMeta91MetaRightMeta92FnFn0

Locks3

Press once and the state stays changed.

CapsLockCapsLock20NumLockNumLock144ScrollLockScrollLock145

System24

Keys that deal with windows and the screen.

EscapeEscape27PrintScreenPrintScreen44PausePause19ContextMenuContextMenu93AudioVolumeMuteAudioVolumeMute173AudioVolumeDownAudioVolumeDown174AudioVolumeUpAudioVolumeUp175MediaTrackNextMediaTrackNext176MediaTrackPreviousMediaTrackPrevious177MediaStopMediaStop178MediaPlayPauseMediaPlayPause179LaunchMailLaunchMail180LaunchApp2LaunchApp2183LaunchApp1LaunchApp1182BrowserBackBrowserBack166BrowserForwardBrowserForward167BrowserRefreshBrowserRefresh168BrowserStopBrowserStop169BrowserSearchBrowserSearch170BrowserFavoritesBrowserFavorites171BrowserHomeBrowserHome172PowerPower0SleepSleep95WakeUpWakeUp0

Input method7

Keys that switch the input method — Hangul, Hanja and the Japanese conversion keys.

Lang1HangulMode21Lang2HanjaMode25ConvertConvert28NonConvertNonConvert29KanaModeKanaMode21IntlRo"\"193IntlYen"\"255

How to read this

  • code is the position, key is the character typed. Match on code for shortcuts.
  • keyCode is deprecated; use it only to read old code.
  • Left and right Shift share a keyCode and are told apart by location.
  • The 1 on the number row and the 1 on the numpad are different keys — 49 and 97.

Frequently asked questions

QShould I use code or key?

code when you need the position, as for shortcuts; key when you need what was typed. code survives a change of layout.

QWhy avoid keyCode?

It was dropped from the standard and browsers disagree on the values, especially for punctuation.

QWhat is the key code for Enter?

keyCode 13, code Enter. The Enter on the numpad has code NumpadEnter but the same keyCode 13.

QHow do I tell left Shift from right Shift?

Not by keyCode — both are 16. Use code (ShiftLeft, ShiftRight) or location (1, 2).

QIs code the same on a Korean keyboard?

Yes. Pressing the spot that types ㅁ still reports KeyA, because code names the position.