TTKTheTextKit

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.

Press any keyClick this box first if you want the page to stay still while you test.

Common keys (US layout)

Keyevent.keyevent.codekeyCode
EnterEnterEnter13
EscapeEscapeEscape27
Space" "Space32
TabTabTab9
BackspaceBackspaceBackspace8
DeleteDeleteDelete46
InsertInsertInsert45
Left arrowArrowLeftArrowLeft37
Up arrowArrowUpArrowUp38
Right arrowArrowRightArrowRight39
Down arrowArrowDownArrowDown40
HomeHomeHome36
EndEndEnd35
Page UpPageUpPageUp33
Page DownPageDownPageDown34
Shift (left)ShiftShiftLeft16
Control (left)ControlControlLeft17
Alt (left)AltAltLeft18
Caps LockCapsLockCapsLock20
AaKeyA65
ZzKeyZ90
0 (top row)0Digit048
9 (top row)9Digit957
0 (keypad)0Numpad096
F1F1F1112
F12F12F12123

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]

About 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.