JavaScript Keycode Finder Online

Press any key to see what the browser reports for it: event.key, event.code, the deprecated keyCode and which, location, the Ctrl, Shift, Alt and Meta flags, and the Caps Lock and Num Lock states. The tool writes the matching code for you, from an event.key check to a React onKeyDown handler, and logs the last 20 keydown and keyup events.

Phones and input methods often send keyCode 229 instead of a real key, so a text field shows their beforeinput and input events too. A searchable table lists 143 keys with their code, US key value, legacy keyCode and location, and notes where Firefox or macOS send something else. Everything runs in your browser.

Not capturing

Press any key

Click here or Tab to this box first.

Tab, Space, arrows and browser shortcuts stay in the box while it has focus. Press Esc twice to leave it.

event.code
—The physical key, named for a US keyboard
event.keyCode
—deprecatedLegacy number; varies by browser
event.which
—deprecatedSame as keyCode on keydown and keyup
event.location
—0 standard, 1 left, 2 right, 3 numpad
event.repeat
—true while a held key auto-repeats
event.isComposing
—true inside an IME composition
Modifier flags and getModifierState()
ctrlKey—shiftKey—altKey—metaKey—CapsLock—NumLock—AltGraph—
altKey is ⌥ Option on a Mac. metaKey is ⌘ Command on a Mac and the Windows key on Windows. Lock states come from getModifierState().

Code for this key

Showing Enter until you press a key
document.addEventListener("keydown", (event) => {
  if (event.key === "Enter") {
    // Enter
  }
});

Match the key (event.key). Named keys have the same key value on every layout.

Typing textRead the text from the input event. keydown misses paste, autocorrect and IME text.

ShortcutsUse key, lowercased, so Ctrl+Z follows the Z on the keycap. Add code as a fallback for Cyrillic and other layouts.

Games and positionsUse code. KeyW is the key above S on every layout, even where it types z.

Event log

Last 20 keydown and keyup events, newest first
No events yetPress keys in the box above or type in the text field below.

Text field for phones and input methods

Virtual keyboards and IMEs often send keydown with keyCode 229 and key "Unidentified" or "Process". The characters arrive in beforeinput and input events instead. Type or compose here to see both: keys go to the log above, text events to the table below.

Key code table

143 keys
Keyboard keys with their code, key value on a US layout, legacy keyCode and location
codekeyShift / NumLock offkeyCodelocation
KeyATypes q on AZERTY"a""A"650 Standard
KeyB"b""B"660 Standard
KeyC"c""C"670 Standard
KeyD"d""D"680 Standard
KeyE"e""E"690 Standard
KeyF"f""F"700 Standard
KeyG"g""G"710 Standard
KeyH"h""H"720 Standard
KeyI"i""I"730 Standard
KeyJ"j""J"740 Standard
KeyK"k""K"750 Standard
KeyL"l""L"760 Standard
KeyMTypes a comma on AZERTY"m""M"770 Standard
KeyN"n""N"780 Standard
KeyO"o""O"790 Standard
KeyP"p""P"800 Standard
KeyQTypes a on AZERTY"q""Q"810 Standard
KeyR"r""R"820 Standard
KeyS"s""S"830 Standard
KeyT"t""T"840 Standard
KeyU"u""U"850 Standard
KeyV"v""V"860 Standard
KeyWTypes z on AZERTY"w""W"870 Standard
KeyX"x""X"880 Standard
KeyYTypes z on QWERTZ"y""Y"890 Standard
KeyZTypes w on AZERTY and y on QWERTZ"z""Z"900 Standard
Digit0"0"")"480 Standard
Digit1AZERTY types & here, and 1 only with Shift"1""!"490 Standard
Digit2"2""@"500 Standard
Digit3"3""#"510 Standard
Digit4"4""$"520 Standard
Digit5"5""%"530 Standard
Digit6"6""^"540 Standard
Digit7"7""&"550 Standard
Digit8"8""*"560 Standard
Digit9"9""("570 Standard
BackquoteLeft of 1. Hankaku/Zenkaku on Japanese keyboards"`""~"1920 Standard
Minus"-""_"189Firefox: 1730 Standard
Equal"=""+"187Firefox: 610 Standard
BracketLeftTypes ü on QWERTZ"[""{"2190 Standard
BracketRight"]""}"2210 Standard
BackslashOn UK and other ISO keyboards, the # ~ key beside Enter"\\""|"2200 Standard
SemicolonTypes m on AZERTY and ö on QWERTZ";"":"186Firefox: 590 Standard
QuoteTypes ä on QWERTZ"'""\""2220 Standard
Comma",""<"1880 Standard
Period"."">"1900 Standard
Slash"/""?"1910 Standard
Spacekey is a space character, " "" "—320 Standard
EnterLabelled Return on Apple keyboards"Enter"—130 Standard
TabShift+Tab is still key "Tab", with shiftKey true"Tab"—90 Standard
BackspaceLabelled Delete on Apple keyboards"Backspace"—80 Standard
DeleteFn+Delete on Mac keyboards without this key"Delete"—460 Standard
InsertNot on Apple keyboards"Insert"—450 Standard
ArrowUp"ArrowUp"—380 Standard
ArrowDown"ArrowDown"—400 Standard
ArrowLeft"ArrowLeft"—370 Standard
ArrowRight"ArrowRight"—390 Standard
HomeFn+Left arrow on Mac laptops"Home"—360 Standard
EndFn+Right arrow on Mac laptops"End"—350 Standard
PageUpFn+Up arrow on Mac laptops"PageUp"—330 Standard
PageDownFn+Down arrow on Mac laptops"PageDown"—340 Standard
ShiftLeft"Shift"—161 Left
ShiftRight"Shift"—162 Right
ControlLeft"Control"—171 Left
ControlRightNot on most Apple keyboards"Control"—172 Right
AltLeft⌥ Option on a Mac"Alt"—181 Left
AltRightkey is "AltGraph" on layouts with AltGr. On Windows, AltGr also sends a ControlLeft keydown"Alt"—18225 on Linux when it works as AltGr2 Right
MetaLeft⌘ Command on a Mac, the Windows key on Windows"Meta"—91Firefox on a Mac: 2241 Left
MetaRight"Meta"—9293 in Chrome and Safari on a Mac. Firefox: 91, or 224 on a Mac2 Right
CapsLock"CapsLock"—200 Standard
ContextMenuBetween right Meta and right Control. Not on Apple keyboards"ContextMenu"—930 Standard
Escape"Escape"—270 Standard
F1On Macs and many laptops, the top row controls brightness and volume unless Fn is held"F1"—1120 Standard
F2"F2"—1130 Standard
F3"F3"—1140 Standard
F4"F4"—1150 Standard
F5"F5"—1160 Standard
F6"F6"—1170 Standard
F7"F7"—1180 Standard
F8"F8"—1190 Standard
F9"F9"—1200 Standard
F10"F10"—1210 Standard
F11"F11"—1220 Standard
F12"F12"—1230 Standard
F13Where PC keyboards have Print Screen"F13"—124Firefox on a Mac: 440 Standard
F14Where PC keyboards have Scroll Lock"F14"—125Firefox on a Mac: 1450 Standard
F15Where PC keyboards have Pause"F15"—126Firefox on a Mac: 190 Standard
F16"F16"—1270 Standard
F17"F17"—1280 Standard
F18"F18"—1290 Standard
F19"F19"—1300 Standard
F20"F20"—1310 Standard
F21"F21"—1320 Standard
F22"F22"—1330 Standard
F23"F23"—1340 Standard
F24"F24"—1350 Standard
PrintScreenWindows usually sends only the keyup; the OS takes the keydown for screenshots"PrintScreen"—44124 in Chrome and Safari on a Mac. 42 on Linux0 Standard
ScrollLock"ScrollLock"—145125 in Chrome and Safari on a Mac0 Standard
Pause"Pause"—19126 in Chrome and Safari on a Mac0 Standard
NumLockOn a Mac this is the Clear key, with key "Clear". Its location is 0, not 3"NumLock"—14412 on a Mac0 Standard
Numpad0"0"NumLock off: "Insert"9645 with NumLock off3 Numpad
Numpad1"1"NumLock off: "End"9735 with NumLock off3 Numpad
Numpad2"2"NumLock off: "ArrowDown"9840 with NumLock off3 Numpad
Numpad3"3"NumLock off: "PageDown"9934 with NumLock off3 Numpad
Numpad4"4"NumLock off: "ArrowLeft"10037 with NumLock off3 Numpad
Numpad5"5"NumLock off: "Clear"10112 with NumLock off3 Numpad
Numpad6"6"NumLock off: "ArrowRight"10239 with NumLock off3 Numpad
Numpad7"7"NumLock off: "Home"10336 with NumLock off3 Numpad
Numpad8"8"NumLock off: "ArrowUp"10438 with NumLock off3 Numpad
Numpad9"9"NumLock off: "PageUp"10533 with NumLock off3 Numpad
NumpadDecimalTypes a comma in locales that use a decimal comma"."NumLock off: "Delete"11046 with NumLock off3 Numpad
NumpadAdd"+"—1073 Numpad
NumpadSubtract"-"—1093 Numpad
NumpadMultiply"*"—1063 Numpad
NumpadDivide"/"—1113 Numpad
NumpadEnterSame key and keyCode as Enter; code and location tell them apart"Enter"—133 Numpad
NumpadEqualMac numeric keypads"="—12187 in Chrome and Safari on a Mac. 61 in Firefox on Mac and Linux3 Numpad
NumpadCommaJapanese and Brazilian keypads","—194188 in Chrome and Safari on a Mac3 Numpad
AudioVolumeMuteMedia and volume keys are often handled by the OS or the browser before the page sees them"AudioVolumeMute"—173Firefox: 1810 Standard
AudioVolumeDown"AudioVolumeDown"—174Firefox: 1820 Standard
AudioVolumeUp"AudioVolumeUp"—175Firefox: 1830 Standard
MediaTrackNext"MediaTrackNext"—1760 Standard
MediaTrackPrevious"MediaTrackPrevious"—1770 Standard
MediaStop"MediaStop"—1780 Standard
MediaPlayPause"MediaPlayPause"—1790 Standard
LaunchMail"LaunchMail"—1800 Standard
MediaSelect"LaunchMediaPlayer"—1810 Standard
LaunchApp1Often labelled My Computer"LaunchApplication1"—1820 Standard
LaunchApp2Often labelled Calculator"LaunchApplication2"—1830 Standard
BrowserBack"BrowserBack"—1660 Standard
BrowserForward"BrowserForward"—1670 Standard
BrowserRefresh"BrowserRefresh"—1680 Standard
BrowserStop"BrowserStop"—1690 Standard
BrowserSearch"BrowserSearch"—1700 Standard
BrowserFavorites"BrowserFavorites"—1710 Standard
BrowserHome"BrowserHome"—1720 Standard
IntlBackslashNot on US (ANSI) keyboards. Types \ and | on UK layouts, < and > on German and FrenchDepends on layout—VariesVaries: often 226 on Windows (VK_OEM_102), 220 on a UK layout0 Standard
IntlRoLeft of the right Shift key on Japanese and Brazilian keyboardsDepends on layout—VariesVaries: 193 or 226 in Chrome on Windows, 189 in Chrome and Safari on a Mac0 Standard
IntlYenLeft of Backspace on Japanese keyboardsDepends on layout—VariesVaries: 255 or 220 in Chrome on Windows, often 0 elsewhere0 Standard
ConvertJapanese keyboards, right of Space"Convert"—280 Standard
NonConvertJapanese keyboards, left of Space"NonConvert"—290 Standard
Lang1Korean keyboards. Kana key on Japanese Mac keyboards. Support varies by browser and OS"HangulMode"—210 Standard
Lang2Korean keyboards. Eisu key on Japanese Mac keyboards. Support varies by browser and OS"HanjaMode"—250 Standard

code and key values follow the W3C UI Events code and key specifications; key is shown for a US layout. keyCode is the value Chrome, Edge and Safari send on Windows; other values come from MDN's browser tables and can change between browser versions.

Waiting for a key0 events loggedDefault actions blockedProcessed locally

How to use it

  1. Click the capture box or Tab to it, then press any key or shortcut.
  2. Read key, code, keyCode, location and the modifiers, then copy the code for the key or the whole event (⌘↵).
  3. Press Esc twice to leave the box. On a phone, type in the text field instead.

Related tools

ASCII TableReferenceUser-Agent ParserWeb & APIHTML to JSX ConverterConvertString Escape / UnescapeConvert

Next: compare letter keyCodes with character codes in the ASCII Table, or check the browser in a keyboard bug report with the User-Agent Parser.

What this tool does

It listens for keydown and keyup in the capture box and shows each property of the KeyboardEvent. key is the value the key produces with the current layout and modifiers, such as "a", "A", "é" or a named key like "Enter" or "ArrowLeft". code names the physical key after its position on a US keyboard, such as "KeyA" or "Digit1", whatever the layout types there. keyCode and which are the legacy numbers: the UI Events specification keeps them only for old content, and their values for punctuation and some special keys differ between browsers. location is 0 for most keys, 1 or 2 for the left or right Shift, Control, Alt and Meta, and 3 for the numeric keypad. repeat is true while a held key auto-repeats, isComposing is true inside an IME composition, and getModifierState() reports Caps Lock, Num Lock and AltGr. While the box has focus, the site's own shortcuts are paused and, with Block default actions on, preventDefault() stops Tab, Space, arrows, F5 and browser shortcuts where the browser allows it. Press Esc twice to leave the box. The code and key values follow the W3C UI Events code and key specifications.

Example input and output

The A key, with and without Shift
Input
Press A, then Shift+A, on a US layout
Output
keydown  key "a"      code "KeyA"       keyCode 65  location 0
keydown  key "Shift"  code "ShiftLeft"  keyCode 16  location 1
keydown  key "A"      code "KeyA"       keyCode 65  shiftKey true

Shift changes key but not code or keyCode. For letters, keyCode is the code of the uppercase letter, 65 to 90.

The same key on a French AZERTY layout
Input
Press the key right of Tab (Q on a US keyboard) with an AZERTY layout
Output
keydown  key "a"  code "KeyQ"  keyCode 65  location 0

key follows the layout; code still names the US position. WASD controls written with code keep working on AZERTY, where those keys are labelled Z, Q, S and D.

Numpad 7 with Num Lock on and off
Input
Press 7 on the numeric keypad, turn Num Lock off, and press it again
Output
keydown  key "7"     code "Numpad7"  keyCode 103  location 3
keydown  key "Home"  code "Numpad7"  keyCode 36   location 3

code and location stay the same while key and keyCode follow Num Lock. Mac keyboards have no Num Lock; the key in that place is Clear.

Common errors and fixes

Checking event.keyCode or event.which in new code
Both are deprecated, and their values depend on the browser and layout: ; is 186 in Chrome and 59 in Firefox. Compare event.key for characters and named keys, or event.code for physical positions. keyCode 13 is "Enter", 27 is "Escape" and 32 is " ".
WASD game controls break on AZERTY
With event.key, the W position types z on AZERTY, so the controls stop matching. Check event.code ("KeyW", "KeyA", "KeyS", "KeyD"), which names the position. To show the player's own labels, Chromium browsers offer navigator.keyboard.getLayoutMap().
Option shortcuts never match on a Mac
Option types special characters, so Option+S has key "ß" and Option+E has key "Dead". Match Alt and Option shortcuts with event.code and event.altKey instead of event.key.
A Ctrl shortcut does nothing for Mac users
Mac users press ⌘, which sets metaKey, not ctrlKey. Accept event.metaKey || event.ctrlKey for shortcuts such as save and undo, and show ⌘ or Ctrl in your labels to match the platform.
Listening for keypress
keypress is deprecated and fires only for keys that produce a character, plus Enter, so it never sees Escape, arrows or modifiers. Use keydown for keys and beforeinput or input for text.
Enter submits while Japanese or Chinese text is still being composed
Pressing Enter to confirm IME text also sends a keydown for Enter. Ignore keydown when event.isComposing is true or event.keyCode is 229, and handle Enter only after compositionend.

Common use cases

  • Finding the event.key or event.code value for a keyboard shortcut
  • Setting up WASD or arrow-key controls for a browser game
  • Replacing keyCode checks in older code with key or code
  • Debugging shortcuts on AZERTY, QWERTZ and Dvorak layouts
  • Checking what a phone keyboard or IME sends before you handle Enter
  • Telling left from right modifiers, and numpad keys from the main ones

Privacy and security notes

  • Key presses and the text you type are read by JavaScript in this tab and shown on the page. Nothing is sent to DevPrix or stored, and reloading the page clears the log.
  • While the capture box has focus, the site's own shortcuts are paused. Shortcuts the browser or operating system keeps, such as closing a tab or switching apps, never reach the page, so the tool can't see or block them.
  • Share copies the link to this page only; no key presses go into it.

Frequently asked questions

What's the difference between event.key and event.code?

key is what the key produces with the current layout and modifiers: "a", "A", "é", or a name such as "Enter". code is the physical key, named after its position on a US keyboard, so the key right of Tab is always "KeyQ", even when an AZERTY layout types a. Use key for text and for shortcuts named after a letter, and code for games and other position-based controls.

Is keyCode deprecated, and what replaces it?

Yes. The UI Events specification documents keyCode, which and charCode only so old content keeps working, and MDN marks them deprecated. Browsers still send them, but the numbers vary: Chrome sends 186 for the ; key and Firefox sends 59. Use event.key or event.code. The common ones map like this: 13 is "Enter", 27 is "Escape", 32 is " ", and 37 to 40 are "ArrowLeft", "ArrowUp", "ArrowRight" and "ArrowDown".

Why does my phone send keyCode 229 and key "Unidentified"?

Many mobile keyboards, especially on Android, compose text before they commit it, so keydown can't say which character is coming. The UI Events specification tells browsers to report keyCode 229 while an input method is processing a key. Read the text from the beforeinput or input event (its inputType and data) instead, and skip keydown when event.isComposing is true or keyCode is 229.

How do I tell left Shift from right Shift?

Check event.location: 1 means left and 2 means right. event.code says the same with "ShiftLeft" and "ShiftRight". Numpad keys have location 3, so the numpad Enter key has code "NumpadEnter" and location 3, while key is "Enter" for both Enter keys.

Why can't the tool capture ⌘W, Ctrl+Tab or Alt+Tab?

The browser or the operating system handles some shortcuts before the page sees them, such as closing and switching tabs or switching apps. Others, such as ⌘S or F5, do reach the page, and the capture box blocks them with preventDefault(). On a Mac, a key released while ⌘ is held often sends no keyup at all.

How do I leave the capture box with the keyboard?

Press Esc twice in a row. Focus moves to the Capture keys button, and Tab carries on from there. You can also untick Block default actions, and Tab then leaves the box as usual.

Guides