Key Properties
Key History
Last 10 keys pressed — click any chip to reload its details.
ASCII Reference Table
Complete ASCII table (0–255): standard (0–127) and extended (128–255).
| Dec | Hex | Char | HTML Entity | Name / Description |
|---|
How to Use This KeyCode Finder
Frequently Asked Questions
What is the difference between event.key and event.code?
event.code for game controls (WASD positions), and event.key for text input processing.Why is event.keyCode deprecated?
event.keyCode was deprecated because it returns a numeric code tied to a physical key position, not the intended character. On AZERTY keyboards, pressing the A key might return keyCode 81 (which is Q on QWERTY). Modern code should use event.key (for the character) or event.code (for the physical key location). MDN and the W3C recommend against using keyCode in new projects.How do I detect Ctrl+C or Cmd+C combinations?
if (event.key === 'c' && (event.ctrlKey || event.metaKey)) { /* copy! */ }. The event.ctrlKey property is true when Ctrl is held (Windows/Linux), and event.metaKey is true when Cmd is held (Mac). Always check both for cross-platform compatibility. Some browsers also support event.modifiers for more granular checks.What is the ASCII code for the Enter key?
How do I detect arrow keys and function keys?
event.key: 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'F1' through 'F12', 'Home', 'End', 'PageUp', 'PageDown'. Or use event.code which gives the same values. For game input, event.code is preferred because it's independent of keyboard layout. The event.location property distinguishes left vs right modifier keys (1=Left, 2=Right).What is a KeyCode?
A keycode (or key code) is a numeric identifier that represents which key on a keyboard was pressed. In JavaScript, keyboard events carry multiple properties that describe the key: event.key gives the character value (like "a" or "Enter"), event.code identifies the physical key (like "KeyA" or "Enter"), and event.keyCode — the legacy numeric representation — returns a number like 65 for the A key. Understanding these properties is essential for web developers building forms, games, keyboard shortcuts, or any interactive application that responds to keyboard input.
The concept of key codes dates back to the earliest days of computing, when terminals communicated using 7-bit ASCII character codes over serial connections. Different systems used different mappings between physical keys and character codes — IBM PCs used scan code set 1, Macintosh used a completely different mapping, and Unix terminals used yet another. JavaScript's keyCode property originally reflected these platform-specific values, which made cross-browser keyboard handling notoriously difficult until the standardization of event.key and event.code in the UI Events specification (DOM Level 3).
event.key vs event.code vs event.keyCode
| Property | Type | Status | Example (A key) | Example (Enter) | Best Use |
|---|---|---|---|---|---|
| event.key | String | ✅ Current standard | "a" or "A" | "Enter" | Text input, character detection |
| event.code | String | ✅ Current standard | "KeyA" | "Enter" | Game controls, physical key binding |
| event.keyCode | Number | ⚠ Deprecated | 65 | 13 | Legacy support only |
| event.which | Number | ⚠ Deprecated | 65 | 13 | jQuery legacy — do not use |
| event.charCode | Number | ⚠ Deprecated | 97 or 65 | 0 (non-printable) | Character code (keypress only) |
Keyboard Event Modifier Properties
Every keyboard event includes boolean modifier flags that indicate which modifier keys were held down during the key press:
- event.ctrlKey — True if the Control key was held. Used for shortcuts like Ctrl+C (copy), Ctrl+V (paste), Ctrl+Z (undo).
- event.altKey — True if the Alt key (Option on Mac) was held. Often used for menu access and alternate character input.
- event.shiftKey — True if the Shift key was held. Changes event.key from lowercase to uppercase for letter keys.
- event.metaKey — True if the Meta key was held (⌘ Command on Mac, ⊞ Windows key on Windows). Used for system-level shortcuts like Cmd+S (save) or Cmd+Q (quit).
- event.repeat — True if the key is being held down and auto-repeating. Useful to distinguish initial press from sustained hold.