Keycode finder
Press any key to see its name and every code your browser gets.
Press any key to see its codes.
Press any key
event.keyWhat the key types or does- …
event.codeWhich key it is: its place on the keyboard- …
event.keyCodeOld number code, deprecated but still sent- …
Type here to see what an on-screen keyboard or input method sends.
All event details
event.which- …The same number as keyCode. Also deprecated.
event.location- …Tells apart keys that come twice: left, right or number pad.
- Modifier keys
- …Held down during this key: ctrlKey, shiftKey, altKey, metaKey.
event.repeat- …true when the key is held down and repeating.
event.isComposing- …true while an input method builds a character (Chinese, Japanese, Korean).
- On your layout
- …What this key types on your keyboard layout, without Shift (Keyboard Map API). It may show your main layout rather than the one in use.
getModifierState()- …Every modifier and lock the browser reports. Off can also mean the browser doesn't report that one.
Code to use it
Press a key and its code shows here.
Event log (no events yet)
Events show here when you press a key.
Using only a keyboard? Press Esc, then Tab, to leave the key box.
Quick start
- Press any key. On a phone, tap the Text box first.
- Read its name, event.key, event.code and keyCode.
- Press Copy next to a value, or Copy code for a snippet.
How to read your results
| What you see | What it means |
|---|---|
| The big key | The key you pressed, by name, with any modifier keys you held: Left Shift, Ctrl + S, Numpad Enter. |
| event.key | What the key types or does: “a”, “A” with Shift, “Enter”, “ArrowUp”. It changes with your keyboard layout and with Shift. |
| event.code | Which key it is: its place on the keyboard, such as “KeyA” or “ShiftRight”. It’s the same on every layout. |
| event.keyCode | The old number for the key, such as 65 for A. It’s deprecated, but browsers still send it. |
| event.location | 0 for most keys, 1 for a left key, 2 for a right key, 3 for the number pad. |
| Modifier keys | Which of Ctrl, Shift, Alt and Meta (Windows key or Cmd) were held down. |
| On your layout | What the key types on your keyboard layout, without Shift. Only Chrome and Edge on a computer can tell. |
| getModifierState() | Every modifier and lock the browser reports, such as Caps Lock and Num Lock, on or off. |
| Event log | Every keydown, keyup and text event, newest first. |
Which value should I use?
- event.code for keys that matter by their place: game controls (WASD), shortcuts, a piano on the keyboard.
- event.key for keys that matter by their meaning: Enter, Escape, the arrows, or a typed character such as “?”.
- Not keyCode or which in new code. They are deprecated and differ between browsers.
Tip: Under Code to use it, the tool writes the JavaScript for the key you just pressed, with the modifier keys you held.
Key code table
| Key | event.code | event.key | keyCode | keyCode in Firefox |
|---|---|---|---|---|
| Backspace | Backspace | Backspace | 8 | |
| Tab | Tab | Tab | 9 | |
| Enter | Enter | Enter | 13 | |
| Numpad Enter | NumpadEnter | Enter | 13 | |
| Left Shift | ShiftLeft | Shift | 16 | |
| Right Shift | ShiftRight | Shift | 16 | |
| Left Control | ControlLeft | Control | 17 | |
| Right Control | ControlRight | Control | 17 | |
| Left Alt | AltLeft | Alt | 18 | |
| Right Alt | AltRight | Alt | 18 | |
| Pause | Pause | Pause | 19 | |
| Caps Lock | CapsLock | CapsLock | 20 | |
| Escape | Escape | Escape | 27 | |
| Space | Space | " " | 32 | |
| Page Up | PageUp | PageUp | 33 | |
| Page Down | PageDown | PageDown | 34 | |
| End | End | End | 35 | |
| Home | Home | Home | 36 | |
| Left Arrow | ArrowLeft | ArrowLeft | 37 | |
| Up Arrow | ArrowUp | ArrowUp | 38 | |
| Right Arrow | ArrowRight | ArrowRight | 39 | |
| Down Arrow | ArrowDown | ArrowDown | 40 | |
| Print Screen | PrintScreen | PrintScreen | 44 | |
| Insert | Insert | Insert | 45 | |
| Delete | Delete | Delete | 46 | |
| 0 to 9 | Digit0 to Digit9 | 0 to 9 | 48 to 57 | |
| A to Z | KeyA to KeyZ | a to z | 65 to 90 | |
| Left Windows | MetaLeft | Meta | 91 | |
| Menu | ContextMenu | ContextMenu | 93 | |
| Numpad 0 to Numpad 9 | Numpad0 to Numpad9 | 0 to 9 | 96 to 105 | |
| Numpad Multiply | NumpadMultiply | * | 106 | |
| Numpad Plus | NumpadAdd | + | 107 | |
| Numpad Minus | NumpadSubtract | - | 109 | |
| Numpad Decimal | NumpadDecimal | . | 110 | |
| Numpad Divide | NumpadDivide | / | 111 | |
| F1 to F12 | F1 to F12 | F1 to F12 | 112 to 123 | |
| Num Lock | NumLock | NumLock | 144 | |
| Scroll Lock | ScrollLock | ScrollLock | 145 | |
| Mute | AudioVolumeMute | AudioVolumeMute | 173 | 181 |
| Volume Down | AudioVolumeDown | AudioVolumeDown | 174 | 182 |
| Volume Up | AudioVolumeUp | AudioVolumeUp | 175 | 183 |
| Semicolon | Semicolon | ; | 186 | 59 |
| Equal | Equal | = | 187 | 61 |
| Comma | Comma | , | 188 | |
| Minus | Minus | - | 189 | 173 |
| Period | Period | . | 190 | |
| Slash | Slash | / | 191 | |
| Backquote | Backquote | ` | 192 | |
| Left Bracket | BracketLeft | [ | 219 | |
| Backslash | Backslash | \ | 220 | |
| Right Bracket | BracketRight | ] | 221 | |
| Quote | Quote | ' | 222 |
Remapping a key
Remapping apps use their own key names, so you don’t paste these values into them. Use the big key’s name and event.code to be sure which key is which. Then pick the key in the app. In PowerToys Keyboard Manager and Karabiner-Elements, you can press the key to pick it.
If something’s wrong
Nothing shows when you press a key
Click the key box first. Keys also count from the page itself, but only while the key box is on your screen. Keys typed into the menu search or other fields don’t count.
A key shows nothing at all
Your keyboard or computer keeps some keys for itself, so the browser never gets them. Fn, brightness keys and many media keys work this way. No website can see these keys.
On Windows, Print Screen sends only a keyup, so it shows when you let go of it.
A shortcut closed the tab or opened a window
Browsers keep some shortcuts: Ctrl + N, Ctrl + T, Ctrl + W, Ctrl + Tab, Ctrl + Page Up, Ctrl + Page Down and Ctrl + 1 to Ctrl + 9 on Windows, and Cmd + N, Cmd + T, Cmd + W and Cmd + Q on a Mac. Your computer keeps others, such as Alt + F4, Windows + L and Ctrl + Alt + Del. The Windows key on its own opens the Start menu. The page never gets these keys. Other shortcuts, such as Ctrl + S or F5, show in the key box without doing anything.
On an Android phone, the key is “Unidentified” and keyCode is 229
The keyboard on your screen doesn’t tell websites which key you tapped. It only sends the text. Look for the input event in the event log: its data shows what you typed (for a deletion, data is empty and inputType says what happened). To see real key codes, connect a Bluetooth or USB keyboard.
iPhones usually send the real key and keyCode, but event.code is often empty.
Typing Chinese, Japanese or Korean shows keyCode 229
Your input method builds each character from several keys, so keys show keyCode 229 or key “Process”, and isComposing is true while it works. Browsers differ at the first and last key. Read the finished text from the compositionend or input event. More in keyCode 229 and “Unidentified” keys.
The key shows “Dead”
It’s a dead key: it waits for your next key to put an accent on it, such as ´ then e for é. Layouts with accents have them. The key box shows which key it is. To see the accented letter, type the two keys in the Text box.
AltGr also turns on Ctrl and Alt
On Windows, AltGr works as Ctrl and Alt together. Chrome and Edge send a Left Control keydown first, then Right Alt, and ctrlKey and altKey are both true. getModifierState(“AltGraph”) is true too, but Ctrl + Alt can also count as AltGr, so it can’t always tell them apart.
The key types the wrong character
If event.code is right but event.key is wrong, your computer uses another keyboard layout. Change it in your computer’s language or keyboard settings. If event.code is wrong too, something remaps the key: a remapping app, or your keyboard’s own software.
On a Mac, keys pressed with Cmd held show no keyup
macOS doesn’t send the keyup of keys pressed while Cmd is held, so browsers can’t always report it.
keyCode is different in another browser
Firefox usually sends other numbers for a few keys, such as 59 for the ; key where Chrome sends 186 on a US keyboard. Punctuation keys also change with the keyboard layout. Use event.code or event.key instead.
How this test works
When you press a key, your browser sends the page a keydown event, and a keyup event when you let go. The tool shows the values exactly as your browser sent them. Nothing is changed or guessed, except the key’s name, which comes from event.code.
Inside the key box, the tool stops each key’s usual action, so F5 or Ctrl + S show their codes instead of reloading or saving. Press Esc, then Tab, to leave the key box.
The text box shows what an on-screen keyboard or input method sends. There the text appears as usual, and the event log also lists the beforeinput, input and composition events.
What the tool can see
- Every key your browser passes to the page, with all its values.
- What a key types on your layout, in Chrome and Edge on a computer (Keyboard Map API). It may show your main layout rather than the one in use.
What it can’t see
- Keys your keyboard or computer keeps for itself, such as Fn.
- Shortcuts your browser or computer keeps, such as Ctrl + W or Alt + F4.
- Scan codes and Windows virtual-key codes.
See how we test keyboards for where our limits come from, and what a browser can’t measure.
Questions and answers
What is a keycode?
A keycode tells a website which key you pressed. Your browser sends it with every key press, for example 13 for Enter and 65 for A.
Today there are three values. event.key is what the key types or does. event.code is which key it is on the keyboard. event.keyCode is the old number, still sent but deprecated.
What's the difference between event.key and event.code?
event.code names the key's place on the keyboard, such as KeyQ for the key right of Tab. It stays the same on every layout, so it suits games (WASD) and shortcuts.
event.key is what the key types: "q" on a US keyboard, "a" on a French one, "Q" with Shift. Use it when the character matters.
Is keyCode deprecated? What should I use instead?
Yes. keyCode, which and charCode are deprecated. Browsers still send them, so old code keeps working, but the numbers differ between browsers and keyboard layouts. In new code, use event.key or event.code.
Why do I get keyCode 229?
229 means an input method or an on-screen keyboard took the key. Android keyboards send it for almost every key, with event.key "Unidentified". iPhones usually send the real key. Japanese, Chinese and Korean typing send it while a character is being built. Read the text from the input event instead.
What key am I pressing?
Press it in the key box. The big key shows its name, such as Right Alt or Numpad Enter. The event.code value beside it names the exact key, the same on every keyboard layout.
Can I see a key's scan code?
No. Browsers don't give websites the scan code or the Windows virtual-key code. On Windows, AutoHotkey's Key History window shows both.
Does this site record what I type?
No. The page shows your key presses on your screen only. It doesn't save or send them.