KeyboardTest.io

Keyboard Event Viewer

0 events
Latest 200 kept
EventkeycodekeyCodeLocModifiersRepeatΔ ms

Every keyboard event appears here, newest first.

Default actions

key, code and keyCode

3 properties

A KeyboardEvent identifies a press in three ways. On a French AZERTY keyboard, the same physical key gives a different key value, the same code, and a keyCode that follows the letter.

PropertyWhat it givesQWERTYAZERTY
keyThe character the layout types, or the key's name (Enter, Shift)qa
codeThe physical key, whatever the layoutKeyQKeyQ
keyCodeA legacy number, deprecated but still sent8165
Use code for shortcuts by position (WASD), and key for text and shortcuts by letter.

location

4 values

The location property says which side a paired key is on, or that a key is on the number pad.

0 · StandardMost keys, which appear once on the board
1 · LeftLeft Shift, Ctrl, Alt and Meta
2 · RightRight Shift, Ctrl, Alt and Meta
3 · NumpadKeys on the number pad, Enter included

Input methods and keyCode 229

IME

With a Chinese, Japanese or Korean input method on, the input method takes the keys first. The page sees key "Process" and keyCode 229, and the text arrives in composition events. Typing ni for a Chinese word:

  1. keydownkey "Process" · keyCode 229
  2. compositionstartThe input method starts a word
  3. compositionupdatedata n, then ni
  4. keydownSpace picks a candidate
  5. compositionenddata is the word picked
  6. inputinputType insertCompositionText
Check isComposing before acting on a key, or the Enter that picks a word also submits the form.

Modifier keys

getModifierState

Each event carries the modifiers held at that moment. getModifierState() also reports the lock keys.

ShiftshiftKey
ControlctrlKey
AltaltKey
MetametaKey (Windows, or Command on a Mac)
CapsLockLock state, not whether the key is down
NumLockLock state, often unknown on a Mac
AltGraphRight Alt on many European layouts
ScrollLockRare on current keyboards

Frequently asked questions

8 questions

What is the difference between event.key and event.code?

Character vs physical key

key is what the key types on the current layout, such as a or A. code is the physical key, such as KeyA, and stays the same on any layout. This keyboard event viewer shows both for every press.

Why is keyCode 229?

Input method

An input method (IME) is handling the key. key reads "Process" and the text comes later in composition and input events. Type in the field to see them.

Is keyCode deprecated?

Yes

keyCode, which and charCode are deprecated, but browsers still send them. New code should read key or code.

Why does Fn not show any event?

Never sent

The keyboard handles Fn itself and sends no key code, so no web page receives it. The key you press with Fn, such as F5 or a volume key, does show up.

Why can't I catch Ctrl+W or Ctrl+T?

Kept by the browser

The browser keeps some shortcuts for itself: close tab, new tab, new window. Blocking default actions stops most other keys, such as Tab, F5 or /, but not these.

Why does a held key keep firing keydown?

Auto-repeat

The system repeats a held key. Each repeat is a keydown with repeat true, and one keyup comes on release.

Why are some keyup events missing on a Mac?

Command held

While Command is held, macOS browsers send no keyup for the other keys, and none arrives after Command is released either. Mac keyboard test →

Does this upload my keystrokes?

Not by the test

Events are handled in this browser only. The test code does not upload them, and they are cleared when you close the page. Privacy policy →