ZYBERMART

Keycode Finder

Press any key to see its JavaScript event.key, event.code, keyCode and modifier values.

Press any key

⌨

Click here first if nothing happens, then press a key.

CtrlShiftAlt / OptionMeta / ⌘

Recent keys

keycodekeyCodeModifiers
Keys you press will appear here.

Common keys

Keyevent.keyevent.codekeyCode
EnterEnterEnter13
EscapeEscapeEscape27
Space" "Space32
TabTabTab9
BackspaceBackspaceBackspace8
Arrow left / up / right / downArrowLeft …ArrowLeft …37–40
A–Za–zKeyA–KeyZ65–90
0–9 (top row)0–9Digit0–Digit948–57
F1–F12F1–F12F1–F12112–123

Example

document.addEventListener('keydown', (event) => {
  if (event.key === 'Escape') closeDialog();
  if ((event.ctrlKey || event.metaKey) && event.key === 's') {
    event.preventDefault();
    save();
  }
});

Frequently asked questions

What is the difference between key and code?

event.key is the character or action the key produces, which depends on the keyboard layout and Shift (for example "a", "A" or "Enter"). event.code is the physical key position, which stays the same on every layout (for example "KeyA").

Should I still use keyCode?

No. event.keyCode and event.which are deprecated and differ between browsers and layouts. Use event.key for text and shortcuts, and event.code for games or position-based controls. They're shown here for older code you may still be maintaining.

Why doesn't a key show up?

Some keys are handled by the operating system or browser before the page sees them, such as the Windows key, Print Screen, or shortcuts like Ctrl+W. The Fn key usually isn't sent to web pages at all.

Does it work on phones?

On-screen keyboards often report key as "Unidentified" and keyCode as 229 while typing. For reliable results, use a physical keyboard.