Key Code Reference

Interactive JavaScript keyboard event codes. Press any key to inspect event properties instantly.

Press any key
Click here or just start typing to capture key events
event.key
event.code
event.keyCode
event.which
event.location
Ctrl Shift Alt Meta

Code Snippet

// Press a key above to generate a snippet

Key Code Table

Keyevent.keyevent.codekeyCodeCategory

Real-time Capture

Press any key and instantly see event.key, event.code, event.keyCode, event.which, and event.location values.

Full Key Reference

Browse a comprehensive table of all common keyboard keys organized by category — letters, numbers, function keys, and more.

Code Snippet Generator

Automatically generates ready-to-use JavaScript event listener snippets based on the key you pressed.

Modifier State Tracking

Visual indicator shows which modifier keys (Ctrl, Shift, Alt, Meta) are active during key presses.

Frequently Asked Questions

What is the difference between event.key and event.code?
event.key returns the character or key label (e.g. "a", "Enter", "1") and changes based on keyboard layout and modifier state. event.code returns the physical key on the keyboard (e.g. "KeyA", "Enter", "Digit1") and stays the same regardless of layout.
Is event.keyCode deprecated?
Yes, event.keyCode and event.which are deprecated in the Web standard. You should prefer event.key or event.code for new code. This tool shows them for legacy reference and debugging.
What does event.location mean?
event.location indicates the physical location of the key on the keyboard: 0 = standard, 1 = left, 2 = right, 3 = numpad. Useful for distinguishing left vs right Shift/Ctrl/Alt keys.

Get Keyboard Tips in Your Inbox

Subscribe for JavaScript event handling tips and web dev updates.