toolfree

Keyboard test

Press a key and see its event.key, event.code and keyCode. Test a keyboard for dead or repeating keys, and learn which property to bind a shortcut to.

Runs in your browser

Press any key
Waiting for a key…
event.key
event.code
event.keyCode
Location
Modifiers

With capture on, Tab and the arrow keys are reported instead of moving focus or scrolling. Turn it off to use the page normally.

Recent keys

Some keys never reach a web page: the system shortcut keys, Fn on most laptops, and anything the browser claims for itself.

Two things this is for

Testing hardware. Press every key in turn. A key that produces nothing is not reaching the browser; a key that fires repeatedly on one press is chattering; a key that reports the wrong character has a layout problem rather than a hardware one.

Finding the right key code. If you are binding a shortcut and need to know what to compare against, press the key and read it off.

key, code and keyCode

Every key press carries three ways of naming what happened, and picking the wrong one is the single most common reason a shortcut works for its author and not for anyone else.

PropertyAnswersW on QWERTYThe same physical key on AZERTY
event.keywhat character was producedwz
event.codewhich physical key was pressedKeyWKeyW
event.keyCodedeprecated numeric code8787

So:

Getting this backwards is why some browser games are unplayable on a French keyboard: they bound WASD to key, and on AZERTY those letters are in the wrong places.

Why keyCode is shown but should not be used

keyCode is deprecated in the UI Events specification and has been for years. It is still here because every browser still fires it and a great deal of existing code still reads it, so seeing the number is genuinely useful when debugging that code.

It should not be used in anything new. It conflates character and position, its values were never fully standardised across browsers, and it has no meaning at all for keys that produce no character.

Keys that never reach a web page

Some of the keyboard is not the page’s to see, and this is by design rather than a fault:

If a key produces nothing here, check it in a text editor before concluding the keyboard is faulty.

Dead keys and input methods

On a layout with dead keys — the accent keys on many European layouts — the first press fires with key set to Dead and produces no character. The character appears only when the following key is pressed.

With a Chinese, Japanese or Korean input method active, keystrokes go to the IME first. event.key reports Process, and the text that eventually arrives comes through composition events instead. This is why a keyboard handler that only listens for keydown loses CJK input entirely, and why text fields should listen for input rather than assembling characters from key events.

Capturing Tab and the arrows

Those keys are off by default here. Tab moves focus and the arrow keys scroll, and a page that swallows them has taken keyboard navigation away from anyone who relies on it. Turn capture on to see them reported, and off again to use the page normally.

Everything stays in the browser

Key presses are read and displayed. Nothing is logged, stored or sent — which for a page that watches everything you type is worth stating plainly.