JavaScript Key Code Viewer
Press any key and see what your browser reports for it: event.key, event.code, the old keyCode number, the location and the modifier keys held. Copy ready JavaScript that detects the key or shortcut, and look up common values in the table.
Common keys (US layout)
| Key | event.key | event.code | keyCode |
|---|---|---|---|
| Enter | Enter | Enter | 13 |
| Escape | Escape | Escape | 27 |
| Space | " " | Space | 32 |
| Tab | Tab | Tab | 9 |
| Backspace | Backspace | Backspace | 8 |
| Delete | Delete | Delete | 46 |
| Insert | Insert | Insert | 45 |
| Left arrow | ArrowLeft | ArrowLeft | 37 |
| Up arrow | ArrowUp | ArrowUp | 38 |
| Right arrow | ArrowRight | ArrowRight | 39 |
| Down arrow | ArrowDown | ArrowDown | 40 |
| Home | Home | Home | 36 |
| End | End | End | 35 |
| Page Up | PageUp | PageUp | 33 |
| Page Down | PageDown | PageDown | 34 |
| Shift (left) | Shift | ShiftLeft | 16 |
| Control (left) | Control | ControlLeft | 17 |
| Alt (left) | Alt | AltLeft | 18 |
| Caps Lock | CapsLock | CapsLock | 20 |
| A | a | KeyA | 65 |
| Z | z | KeyZ | 90 |
| 0 (top row) | 0 | Digit0 | 48 |
| 9 (top row) | 9 | Digit9 | 57 |
| 0 (keypad) | 0 | Numpad0 | 96 |
| F1 | F1 | F1 | 112 |
| F12 | F12 | F12 | 123 |
Some key presses never reach a web page, because the operating system or the browser takes them first. What you type is shown on this page only and is not stored or sent anywhere. Do not type passwords into any key tester.
Related Tools
[6 suggestions]Unicode Character Inspector
See every code point in your text with its U+ number, category, script, UTF-8 bytes and UTF-16 units, and spot hidden characters.
Developer & WebASCII Table
A searchable ASCII chart of all 128 characters with decimal, hexadecimal, octal and binary values, names and escape sequences.
Developer & WebTyping Speed Test: Words Per Minute and Accuracy
Test your typing speed in words per minute with live feedback on mistakes, net and gross speed, accuracy and a choice of 30 second, 1 minute or 2 minute tests.
Analysis & CountingString Escape and Unescape Tool
Escape or unescape text for JSON, JavaScript, CSV, SQL, MySQL, regular expressions and shell commands, with the options each needs.
Developer & WebRegex Tester
Test regular expressions against a string, highlight matches, and inspect capture groups.
Developer & WebJSON Formatter
Validate, pretty-print, and minify JSON with clear error reporting for invalid input.
Developer & WebAbout the JavaScript Key Code Viewer
When someone presses a key, the browser sends a keyboard event with several values. The key property says what the key means, taking Shift and the keyboard layout into account: the same physical key can give a, A or q. Printable keys report the character, and others report a name such as Enter, ArrowLeft or Escape. The code property names the physical key, such as KeyQ or Digit2, and does not change with layout or modifiers, so it suits game controls like WASD, where position matters. The keyCode property is an older number, for example 13 for Enter. It is deprecated, which means new code should use key or code instead, but you still meet it when reading older scripts. This viewer shows all three together with the location, which tells left Shift from right Shift and the number keypad from the top row, and a history of recent presses. The code sample can test by key or by code and includes the modifiers you held, so a shortcut such as Ctrl plus K is easy to copy. Click the test area first if you do not want the page to scroll or react to keys; Tab and shortcuts with Ctrl or Command are left to the browser. Some combinations never reach a web page because the operating system or browser uses them. On phones and tablets, on-screen keyboards often report Unidentified or the code 229 while composing text, so test there with the input event if you need the typed characters. The table lists values as a US keyboard reports them. Do not type passwords into any key testing page.
What is the key code for Enter?▾
The old keyCode is 13. In modern code, test event.key === "Enter".
What is the difference between event.key and event.code?▾
event.key is the value the key produces and follows the layout and Shift. event.code names the physical key and stays the same on every layout.
Is keyCode still supported?▾
Browsers still provide it, but it is deprecated, so avoid it in new code.
Why do I get keyCode 229?▾
It usually means the keyboard is composing text, as many on-screen keyboards and input methods do, so the individual key is not reported.
Why does my shortcut not show up?▾
The browser or the operating system handles it before the page sees it, as with closing a tab.
Are my key presses recorded?▾
They are shown on the page only. Nothing is stored or sent.