JavaScript KeyCode & KeyboardEvent Checker
Interactive keyboard event debugger. Inspect event.key, event.code, keyCode, which, modifier keys, and location values in real-time.
Carriage return / Submit line break key.
Modifier Flags & Keyboard State
Active toggles glow during keystrokeSearch & Keycode Lookup
Don't have a physical key? Enter a character, name, or numeric keycode (e.g. "Enter", "13", "Space", "KeyA")
// 1. Recommended: event.key (Value-based, respects layout & modifiers)
window.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
event.preventDefault();
console.log('Detected key:', event.key);
// Your application logic here
}
});| Key Name | event.key | event.code | keyCode | Category | Action |
|---|---|---|---|---|---|
| Backspace | "Backspace" | Backspace | 8 | Control | |
| Tab | "Tab" | Tab | 9 | Control | |
| Enter | "Enter" | Enter | 13 | Control | |
| Shift (Left) | "Shift" | ShiftLeft | 16 | Modifiers | |
| Shift (Right) | "Shift" | ShiftRight | 16 | Modifiers | |
| Control (Left) | "Control" | ControlLeft | 17 | Modifiers | |
| Control (Right) | "Control" | ControlRight | 17 | Modifiers | |
| Alt (Left) | "Alt" | AltLeft | 18 | Modifiers | |
| Alt (Right) | "Alt" | AltRight | 18 | Modifiers | |
| Pause / Break | "Pause" | Pause | 19 | Control | |
| Caps Lock | "CapsLock" | CapsLock | 20 | Modifiers | |
| Escape | "Escape" | Escape | 27 | Control | |
| Spacebar | " " | Space | 32 | Standard | |
| Meta (Left Cmd/Win) | "Meta" | MetaLeft | 91 | Modifiers | |
| Meta (Right Cmd/Win) | "Meta" | MetaRight | 92 | Modifiers | |
| Context Menu | "ContextMenu" | ContextMenu | 93 | Control | |
| IME Composition | "Unidentified" | Unidentified | 229 | Control | |
| Page Up | "PageUp" | PageUp | 33 | Navigation | |
| Page Down | "PageDown" | PageDown | 34 | Navigation | |
| End | "End" | End | 35 | Navigation | |
| Home | "Home" | Home | 36 | Navigation | |
| Arrow Left | "ArrowLeft" | ArrowLeft | 37 | Navigation | |
| Arrow Up | "ArrowUp" | ArrowUp | 38 | Navigation | |
| Arrow Right | "ArrowRight" | ArrowRight | 39 | Navigation | |
| Arrow Down | "ArrowDown" | ArrowDown | 40 | Navigation | |
| Insert | "Insert" | Insert | 45 | Navigation | |
| Delete | "Delete" | Delete | 46 | Navigation | |
| Digit 0 | "0" | Digit0 | 48 | Standard | |
| Digit 1 | "1" | Digit1 | 49 | Standard | |
| Digit 2 | "2" | Digit2 | 50 | Standard | |
| Digit 3 | "3" | Digit3 | 51 | Standard | |
| Digit 4 | "4" | Digit4 | 52 | Standard | |
| Digit 5 | "5" | Digit5 | 53 | Standard | |
| Digit 6 | "6" | Digit6 | 54 | Standard | |
| Digit 7 | "7" | Digit7 | 55 | Standard | |
| Digit 8 | "8" | Digit8 | 56 | Standard | |
| Digit 9 | "9" | Digit9 | 57 | Standard | |
| Key A | "a" | KeyA | 65 | Standard | |
| Key B | "b" | KeyB | 66 | Standard | |
| Key C | "c" | KeyC | 67 | Standard | |
| Key D | "d" | KeyD | 68 | Standard | |
| Key E | "e" | KeyE | 69 | Standard | |
| Key F | "f" | KeyF | 70 | Standard | |
| Key G | "g" | KeyG | 71 | Standard | |
| Key H | "h" | KeyH | 72 | Standard | |
| Key I | "i" | KeyI | 73 | Standard | |
| Key J | "j" | KeyJ | 74 | Standard | |
| Key K | "k" | KeyK | 75 | Standard | |
| Key L | "l" | KeyL | 76 | Standard | |
| Key M | "m" | KeyM | 77 | Standard | |
| Key N | "n" | KeyN | 78 | Standard | |
| Key O | "o" | KeyO | 79 | Standard | |
| Key P | "p" | KeyP | 80 | Standard | |
| Key Q | "q" | KeyQ | 81 | Standard | |
| Key R | "r" | KeyR | 82 | Standard | |
| Key S | "s" | KeyS | 83 | Standard | |
| Key T | "t" | KeyT | 84 | Standard | |
| Key U | "u" | KeyU | 85 | Standard | |
| Key V | "v" | KeyV | 86 | Standard | |
| Key W | "w" | KeyW | 87 | Standard | |
| Key X | "x" | KeyX | 88 | Standard | |
| Key Y | "y" | KeyY | 89 | Standard | |
| Key Z | "z" | KeyZ | 90 | Standard | |
| Numpad 0 | "0" | Numpad0 | 96 | Numpad | |
| Numpad 1 | "1" | Numpad1 | 97 | Numpad | |
| Numpad 2 | "2" | Numpad2 | 98 | Numpad | |
| Numpad 3 | "3" | Numpad3 | 99 | Numpad | |
| Numpad 4 | "4" | Numpad4 | 100 | Numpad | |
| Numpad 5 | "5" | Numpad5 | 101 | Numpad | |
| Numpad 6 | "6" | Numpad6 | 102 | Numpad | |
| Numpad 7 | "7" | Numpad7 | 103 | Numpad | |
| Numpad 8 | "8" | Numpad8 | 104 | Numpad | |
| Numpad 9 | "9" | Numpad9 | 105 | Numpad | |
| Numpad Multiply | "*" | NumpadMultiply | 106 | Numpad | |
| Numpad Add | "+" | NumpadAdd | 107 | Numpad | |
| Numpad Subtract | "-" | NumpadSubtract | 109 | Numpad | |
| Numpad Decimal | "." | NumpadDecimal | 110 | Numpad | |
| Numpad Divide | "/" | NumpadDivide | 111 | Numpad | |
| Numpad Enter | "Enter" | NumpadEnter | 13 | Numpad | |
| Num Lock | "NumLock" | NumLock | 144 | Modifiers | |
| F1 | "F1" | F1 | 112 | Function | |
| F2 | "F2" | F2 | 113 | Function | |
| F3 | "F3" | F3 | 114 | Function | |
| F4 | "F4" | F4 | 115 | Function | |
| F5 | "F5" | F5 | 116 | Function | |
| F6 | "F6" | F6 | 117 | Function | |
| F7 | "F7" | F7 | 118 | Function | |
| F8 | "F8" | F8 | 119 | Function | |
| F9 | "F9" | F9 | 120 | Function | |
| F10 | "F10" | F10 | 121 | Function | |
| F11 | "F11" | F11 | 122 | Function | |
| F12 | "F12" | F12 | 123 | Function | |
| Semicolon | ";" | Semicolon | 186 | Symbols | |
| Equal | "=" | Equal | 187 | Symbols | |
| Comma | "," | Comma | 188 | Symbols | |
| Minus | "-" | Minus | 189 | Symbols | |
| Period | "." | Period | 190 | Symbols | |
| Slash | "/" | Slash | 191 | Symbols | |
| Backquote / Tilde | "`" | Backquote | 192 | Symbols | |
| Bracket Left | "[" | BracketLeft | 219 | Symbols | |
| Backslash | "\" | Backslash | 220 | Symbols | |
| Bracket Right | "]" | BracketRight | 221 | Symbols | |
| Quote | "'" | Quote | 222 | Symbols | |
| Volume Mute | "AudioVolumeMute" | AudioVolumeMute | 173 | Media | |
| Volume Down | "AudioVolumeDown" | AudioVolumeDown | 174 | Media | |
| Volume Up | "AudioVolumeUp" | AudioVolumeUp | 175 | Media | |
| Media Play/Pause | "MediaPlayPause" | MediaPlayPause | 179 | Media |
Zero-Knowledge Local Execution
All data processing, parsing, and compilation execute strictly inside your local browser memory. Zero external server uploads.
Instant Client-Side Engine
Instant real-time reactive computation delivers immediate feedback on every keystroke with zero network latency.
Production Standards & Compliance
Strictly validates syntax, edge cases, and formatting rules for dependable production output.
Key Code Checker Developer Reference
Technical reference for DOM KeyboardEvent properties, legacy keyCode migration, and cross-platform key detection.
Key Parameters & Controls
| Parameter | Type / Unit | Description | Default |
|---|---|---|---|
| event.key | string | Semantic character value or functional identifier produced by the keystroke (e.g., 'Enter', 'a', 'ArrowDown'). | "" |
| event.code | string | Physical key identifier representing hardware button placement, unaffected by active layout or modifiers (e.g., 'KeyA', 'Space'). | "" |
| event.keyCode | number | Legacy system-dependent virtual key code representing the physical or virtual key (deprecated in W3C UI Events). | 0 |
| event.location | number | Numeric indicator of key area: 0 (Standard), 1 (Left modifier), 2 (Right modifier), 3 (Numpad). | 0 |
| event.isComposing | boolean | Flag indicating whether the event occurs within an active Input Method Editor (IME) text composition session. | false |
Pro Tips & Best Practices
Migrate legacy keyboard listeners from deprecated 'keyCode' and 'which' to W3C-standard 'key' and 'code' to ensure cross-platform consistency across modern browsers.
Check 'event.isComposing' or guard against 'event.keyCode === 229' to avoid premature form submissions when international users confirm input with the Enter key.
Bind position-dependent gaming controls (such as WASD navigation) to 'event.code' rather than 'event.key' so key positions remain invariant across QWERTY, AZERTY, and Dvorak.
Common Gotchas & Troubleshooting
⚠️KeyboardEvent.keyCode returns 229 on mobile virtual keyboards and desktop IME input.
Inspect 'event.isComposing' before executing key actions, or migrate text-entry handling to the standard DOM 'input' event with 'event.inputType'.
⚠️Position-sensitive shortcut keys trigger incorrect actions on international keyboard layouts like AZERTY.
Use 'event.code' (e.g. 'KeyW') for spatial hotkeys and 'event.key' (e.g. 'z' or 'w') when listening for semantic character input.
Frequently Asked Questions
Why are KeyboardEvent.keyCode and KeyboardEvent.which deprecated by the W3C?▼
Both properties are inconsistent across operating systems, browsers, and international keyboards, returning ASCII-derived legacy integers that cannot reliably distinguish between layouts or compose non-Latin characters. The W3C UI Events specification supersedes them with standard 'key' and 'code' properties.
How do KeyboardEvent.key and KeyboardEvent.code behave differently across keyboard layouts?▼
'KeyboardEvent.code' represents the immutable physical key position on the keyboard hardware (e.g., 'KeyQ' on both QWERTY and AZERTY), while 'KeyboardEvent.key' reflects the resolved character string produced in the current active layout (e.g., 'q' on QWERTY vs. 'a' on AZERTY).
What does KeyboardEvent.location indicate in DOM key events?▼
'KeyboardEvent.location' specifies the physical keyboard region: 0 (DOM_KEY_LOCATION_STANDARD), 1 (DOM_KEY_LOCATION_LEFT, e.g. Left Shift), 2 (DOM_KEY_LOCATION_RIGHT, e.g. Right Shift), 3 (DOM_KEY_LOCATION_NUMPAD), and extended vendor values like 4 (Mobile) or 5 (Joystick).
How should single-page applications handle keyboard shortcut registration without memory leaks?▼
Attach key listeners to 'window' or specific focusable DOM containers using 'addEventListener('keydown', handler)' inside a lifecycle hook (e.g., 'useEffect'), and always supply 'removeEventListener' in the teardown cleanup function. Use 'event.preventDefault()' sparingly to avoid disabling essential accessibility and navigation behaviors.
Related Tools & Utilities
All Tools →Check HTTP status codes, test redirect chains, and inspect response headers. Diagnose 1xx to 5xx error codes, RFC specifications, SEO impact, and fixes.
Comprehensive directory of 1xx to 5xx HTTP response codes with RFC specs, caching directives, and troubleshooting guides.
Paste raw curl command and instantly generate clean JavaScript fetch / Axios syntax.
Inspect Unicode strings down to code points (U+XXXX), detect hidden zero-width spaces/bidi overrides, view UTF-8/UTF-16 byte sequences, and analyze grapheme clusters.
Test, debug, and benchmark regular expressions in real-time with capture group extraction, replacement previews, regex flag toggles, and syntax explanations.
Decode 3, 4, 5, and 6-band resistor color codes with tolerance, TCR drift, E-series matching, and SMD equivalents per IEC 60062.