JavaScript Keycode Finder - Online Keyboard Event Tool
Press any key to see the corresponding JavaScript event key, code, and keyCode. An essential debugging tool for front-end developers handling keyboard input.
UD5 Toolkit
Real-time inspection of keydown, keyup & keypress events â see key, code, keyCode, modifiers, and more.
| # | Time | Type | Key | Code | keyCode | Modifiers | Repeat | Location |
|---|---|---|---|---|---|---|---|---|
| No events captured yet. Click the capture zone and press keys. | ||||||||
event.key returns the logical character value of the key pressed â it respects the keyboard layout and modifier state. For example, pressing the Q key on a QWERTY layout returns "q", while on an AZERTY layout it returns "a". With Shift held, it returns "Q" or "A" respectively.
event.code returns the physical key location on the keyboard, independent of layout. The Q key always returns "KeyQ" regardless of keyboard layout. This makes code ideal for game controls (WASD), keyboard shortcuts, and layout-agnostic key handling.
Use event.code for physical key identification (games, shortcuts); use event.key for character input (text fields, editors).
event.keyCode (and event.which) are deprecated because they return numeric codes that are inconsistent across browsers and keyboard layouts. They don't distinguish between upper/lowercase and fail to represent many modern Unicode characters.
Replacements:
event.key for the character value (e.g., "a", "Enter", "ArrowUp").event.code for the physical key (e.g., "KeyA", "Enter", "ArrowUp").Both key and code are supported in all modern browsers and provide much clearer, layout-aware key identification.
The event.location property tells you which physical key was pressed when multiple identical keys exist on a keyboard:
| Value | Constant | Meaning |
|---|---|---|
0 | DOM_KEY_LOCATION_STANDARD | Standard key (most keys) |
1 | DOM_KEY_LOCATION_LEFT | Left-side modifier (e.g., left Shift, left Ctrl) |
2 | DOM_KEY_LOCATION_RIGHT | Right-side modifier (e.g., right Shift, right Alt) |
3 | DOM_KEY_LOCATION_NUMPAD | Numpad keys (e.g., numpad 1-9, numpad Enter) |
This is especially useful for differentiating left/right modifier keys or numpad vs. main keyboard digits.
keydown â Fires when a key is pressed down. Fires for all keys (including modifiers, arrows, function keys). The repeat property is true when a key is held down.keyup â Fires when a key is released. Useful for detecting when a modifier or held key is released.keypress â Deprecated. Fires only for printable character keys. Does not fire for modifiers, arrows, or function keys. Not recommended for new projects.For most use cases, keydown and keyup are sufficient and reliable across all browsers.
When a user holds down a key, the operating system generates repeated keydown events. The event.repeat property is true for these auto-repeated events and false for the initial press.
This is useful for:
keyup events never have repeat: true â they only fire once when the key is physically released.
When users type in languages like Chinese, Japanese, or Korean, they use an Input Method Editor (IME) that combines multiple keystrokes into a single character. During composition, event.isComposing is true.
This is critical because during IME composition:
keydown events may fire for what ultimately becomes one character.isComposing to skip events that are part of an active composition session.if (event.isComposing) return; â this simple guard prevents double-processing of IME input in search boxes, form fields, and editors.
Use the modifier boolean properties on the event object:
document.addEventListener('keydown', (event) => {
if (event.ctrlKey && event.key === 'c') {
console.log('Ctrl+C pressed!');
// Handle copy shortcut
}
if (event.metaKey && event.key === 's') {
console.log('Cmd+S (Mac) pressed!');
event.preventDefault(); // Prevent browser save dialog
}
});
The modifier properties (ctrlKey, shiftKey, altKey, metaKey) reflect the real-time state of modifier keys during the event.
Some keys are intercepted by the browser or operating system before JavaScript can process them:
preventDefault().To maximize key capture, ensure the capture zone is focused and enable "Prevent browser defaults" in this tool. However, some OS-level combinations remain uncapturable for security reasons.
The charCode property is only populated during keypress events (which are now deprecated). In keydown and keyup events, charCode is always 0.
This is because keydown fires before the character value is determined (it represents the physical key press), while keypress fires when a character is actually produced.
For modern development, use event.key instead â it provides the character value reliably across all event types.
Mobile virtual keyboards have notable differences from physical keyboards:
0 or 229 (IME processing) for many keys on Android/iOS.For cross-platform compatibility, always test keyboard handling on both desktop and mobile devices, and prefer event.key for character input scenarios.
Press any key to see the corresponding JavaScript event key, code, and keyCode. An essential debugging tool for front-end developers handling keyboard input.
Press a combination of modifier keys and see which common macOS shortcuts use them. Learn by experimentation.
Fill in event details and generate 'Add to Calendar' links for Google, Outlook, and Yahoo, plus a downloadable .ics file.
Check if a URL can be embedded in an iframe. Test your siteâs defense against clickjacking. Browserâbased.
Encrypt and decrypt text using AES in the browser with a password. Uses Web Crypto API. No data sent to server.
Type a modern English word and get a possible Old English equivalent. Works offline with a limited but curated wordlist. Learn history.
Strip specific or all attributes from HTML tags. Clean up messy code. Keep the structure. Purely local.
Enter a username and password to generate an .htpasswd entry using bcrypt. Runs entirely in browser.
Scale a jerky marinade recipe based on meat weight. Includes optional cure #1 calculation for safety.
Decode SMD resistor markings (3-digit, 4-digit, EIA-96) to resistance value. Enter code and get ohms instantly. Handy for PCB repair.
Split text into a JavaScript or JSON string array. Wrap in quotes, add commas. Ready to paste into code.
Set up multiple @layers and use revertâlayer to fall back. See the computed style and cascade resolution live.
Generate strong random strings for API tokens, session secrets, or encryption keys. Uses crypto.getRandomValues().
Paste code and generate a beautiful, syntaxâhighlighted PNG image. Choose theme and window style. Shareable code pics.
Highlight elements with ariaâdescribedby and see the linked description text. Verify a11y annotations.
Load an image and see the exact events fired (load, error, abort). Monitor progress. Dev helper.
Generate cryptographic key pairs using the Web Crypto API. Export as JWK or raw. No server needed; pure security.
Fill in a form and see the FormData object as JSON. Perfect for debugging multipart form submissions. Client-side.
Adjust root, margin, and threshold. See a live log of intersection events as you scroll. Debug lazy loading.
Inject dynamic messages into ARIA live regions and monitor how they trigger screen reader announcements. Debug a11y.
Start recording and watch for Long Tasks that block the main thread. See task duration and attribution. Improve Interaction to Next Paint.
Touch the screen and see the exact coordinates, radius, and force of each touch point. Indispensable for mobile web devs.
See the current state of a Service Worker for your page: installing, waiting, active. Unregister or skip waiting. Developer utility.
Create a PGP key pair (RSA or ECC) directly in your browser with passphrase protection. Export public/private armored keys. No upload.
Convert any text to snake_case, kebabâcase, camelCase, or PascalCase. Essential for programming variable naming. Local.
Find the currency code (USD, EUR, JPY) for any country or reverseâlookup the country from a code. Static reference.
Paste code and get a beautifully highlighted preview with line numbers. Supports many languages. Copy as HTML. Pure frontend.
Generate random, secure coupon codes with a prefix. Choose length and character set. Perfect for store admins. All local.
Paste a list of JavaScript values and see them prettyâprinted as if in the browser console. Great for debugging.
Enter a JSON pointer expression (/foo/bar) to extract a value from your pasted JSON. Debug nested objects quickly.