Keyboard Event Tester
About this tool
About Keyboard Event Tester
Building a keyboard shortcut, a game control or an accessible widget means knowing exactly what the browser reports when a key is pressed. Click the capture area and press any key: it shows event.key in large type, the shortcut as people would write it (Ctrl + Shift + K, or Cmd + S on a Mac), and every property of the KeyboardEvent: key, code, the deprecated keyCode and which, location (standard, left, right or numpad), the four modifier flags, repeat for held keys and isComposing for IME input. A ready-made if condition for the key you pressed can be copied straight into your handler. The event log records keydown and keyup, plus keypress if you want to see the legacy event, newest first, and can be copied as an aligned text table. Turn on Block browser shortcuts to call preventDefault so combinations such as Ctrl + S or F5 reach the page instead of the browser. Nothing you type is stored or sent anywhere.
Built and maintained by Abhi JainUpdated
How to Test Keyboard Events
- 1
Focus the capture area
Click the yellow area that says Click here, then press any key.
- 2
Read the properties
The key, code, keyCode, location, modifiers and repeat values of the last key appear below, with a copyable if condition.
- 3
Use the log
Every keydown and keyup is listed in the Event log. Turn on Block browser shortcuts to test combinations the browser normally catches, and Copy the log when you're done.
Keyboard Event Tester: questions and answers
What is the difference between event.key and event.code?
event.key is the character or named key produced, which depends on the keyboard layout and Shift ("a", "A", "Enter"). event.code is the physical key position, which stays the same across layouts ("KeyA", "Enter"). Use key for text and shortcuts, code for game-style controls such as WASD.
Is keyCode deprecated?
Yes. keyCode and which are deprecated and inconsistent across layouts and browsers. They still work for compatibility, but new code should use event.key or event.code.
How do I tell the left and right Shift keys apart?
Check event.location (1 is left, 2 is right) or event.code ("ShiftLeft" or "ShiftRight"). The numpad reports location 3.
Why can't I capture Ctrl + W or Cmd + Q?
Some shortcuts are reserved by the browser or operating system and never reach the page, even with preventDefault. Others, such as Ctrl + S or F5, can be captured when Block browser shortcuts is on.
What is isComposing?
It is true while an input method editor (IME) is composing text, for example when typing Japanese, Chinese or Korean. Shortcut handlers should usually ignore events where isComposing is true.
Related Tools
- ASCII TableAll 128 ASCII characters (plus 128–255) with decimal, hex, octal, binary, HTML entities and control codes.
- What Is My BrowserSee your browser, version, OS, screen, viewport, time zone and supported features.
- HTML, CSS & JS PlaygroundWrite HTML, CSS and JavaScript and see a live, sandboxed preview with a console.
- User Agent ParserParse a user agent string into browser, version, engine, OS and device, one or in bulk.