100% FREE • NO SIGNUP

JavaScript Keycode Finder

Press any key to instantly see its keyCode, key, code, which, and location values. Full reference table and code snippets included.

⌨️ Press any key to get started
A
65
event.keyCode
Ctrl Shift Alt Meta
event.key
event.code
event.keyCode (deprecated)
event.which (deprecated)
event.location
event.type

Event Listener Code

// Press a key to generate code...

Key History

Common Keycodes Reference

KeykeyCodeevent.keyevent.code

JavaScript Keyboard Events Guide

JavaScript provides three keyboard events: keydown, keyup, and the deprecated keypress. Each fires with a KeyboardEvent object containing information about the pressed key.

event.key vs event.code vs event.keyCode

PropertyTypeExample (pressing "a")Layout-dependent?
event.keyString"a"Yes
event.codeString"KeyA"No
event.keyCodeNumber65Partially

Modern Best Practices

Keyboard Shortcut Pattern

document.addEventListener('keydown', (e) => {
  // Ctrl+S to save
  if (e.ctrlKey && e.key === 's') {
    e.preventDefault();
    save();
  }
  // Escape to close
  if (e.key === 'Escape') {
    closeModal();
  }
});

Location Values

Frequently Asked Questions

What is event.keyCode in JavaScript?
event.keyCode is a numeric code representing a physical key. For example, Enter = 13, Escape = 27, Space = 32. It's deprecated but still works in all browsers. Use event.key or event.code instead.
What's the difference between key and code?
event.key returns the character value affected by layout and modifiers ("a" vs "A"). event.code returns the physical key position ("KeyA") regardless of keyboard layout. Use key for text input, code for game controls.
Is keyCode deprecated?
Yes, both keyCode and which are deprecated per the W3C spec. The modern replacements are event.key and event.code. However, keyCode still works in all browsers and many libraries still use it.
What keyCode is Enter?
Enter has keyCode 13. In modern code, prefer: if (event.key === 'Enter') or if (event.code === 'Enter') instead of checking the numeric keyCode.
How do I detect arrow keys?
Use event.key: 'ArrowUp' (keyCode 38), 'ArrowDown' (40), 'ArrowLeft' (37), 'ArrowRight' (39). Or use event.code: 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'.

🛠️ Need More Dev Tools?

Check out our 60+ free developer tools — all run in your browser, no signup needed.

Browse All Tools →

Related Tools