curly{bits}

curlybits / Keycode Finder

JavaScript Keycode Finder

Press any key to see exactly what JavaScript receives: event.key, event.code, the old keyCode, its location and which modifier keys are held. A code snippet for that key is ready to copy.

Press any key
event.key–
event.code–
event.keyCode–
event.location–
Modifiers–
event.repeat–
document.addEventListener("keydown", (e) => { … });
Recent keys
keycodekeyCodeModifiers

How to use the JavaScript Keycode Finder

  1. Click anywhere on the page and press a key.
  2. Read event.key, event.code, keyCode and the other values in the boxes.
  3. Copy the snippet to handle that key in your own code.
  4. Recent keys are listed underneath, so you can compare them.

key, code or keyCode?

  • event.key is the character or name the key produces, like "a", "A", "Enter" or "ArrowLeft". It follows the keyboard layout and Shift. Use it for shortcuts and text.
  • event.code is the physical key, like "KeyA" or "Digit1", whatever the layout. Use it for game controls such as WASD, so they work on AZERTY keyboards too.
  • event.keyCode and which are old numeric codes. They're deprecated, but still found in older code, so they're shown for reference.

Common key codes

Keyevent.keyevent.codekeyCode
EnterEnterEnter13
EscapeEscapeEscape27
Space" "Space32
TabTabTab9
BackspaceBackspaceBackspace8
DeleteDeleteDelete46
← ↑ → ↓ArrowLeft, ArrowUp, ArrowRight, ArrowDownsame37, 38, 39, 40
Shift / Ctrl / AltShift, Control, AltShiftLeft, ControlLeft, AltLeft…16, 17, 18
A–Za–z (A–Z with Shift)KeyA–KeyZ65–90
0–90–9Digit0–Digit948–57
F1–F12F1–F12F1–F12112–123

To check that every key on your keyboard works, try the keyboard tester on our sister site.

Frequently asked questions

What is the keycode for Enter?

13. Its event.key and event.code are both "Enter".

Should I still use keyCode?

No. It's deprecated. Use event.key for characters and shortcuts, and event.code for physical positions.

Why don't some keys show up?

The operating system or browser can take some shortcuts first, like Ctrl+W, the Windows key or Print Screen, before the page sees them.

Updated

Add this JavaScript keycode finder to your website

Free for blogs, schools and businesses. Copy the code below and paste it into your page's HTML. The tool works exactly like this one and runs in your visitors' browsers, so nothing is uploaded. Please keep the credit line so others can find it too.

Preview embed ↗