Keycode finder
Press any key to see its JavaScript keyCode, key, code and location, and copy a ready keydown handler. Free, no sign-up, and it runs in your browser.
Click or tap the box, then press a key or a shortcut. Tab still moves to the next field.
Press a key in the box above to see its keyCode, key, code and location.
Keycode list
Values for a US keyboard in Chrome, Edge and Safari. Search by key name, code or keyCode number.
What this keycode finder does
Press any key and the tool shows every value a JavaScript keydown event reports for it: keyCode, key, code, which and location, plus which modifier keys were held and whether the key was repeating. It also writes a ready keydown handler that matches the key you pressed, so you can paste it into your code. Below that is a searchable keycode list for a US keyboard.
The tool reads the same events your own code gets. Nothing you type is stored or sent anywhere.
How to use it
- Click or tap the box at the top, then press a key or a shortcut such as Ctrl+K or Shift+Enter.
- Read the big number for the old
keyCodevalue, and the cards forkey,code,whichandlocation. Use the copy icon on a card to copy that value. - Under Code for this key, choose whether to match
event.keyorevent.code, then select Copy code. - Press more keys to compare them in Recent keys. To look a key up without pressing it, search the Keycode list by name, code or number (for example
27finds Escape).
Most browser shortcuts are blocked while the box has focus, so you can test keys such as Space, the arrow keys or Ctrl+S without the page reacting. Tab is not blocked, so you can still leave the box with the keyboard. A few system shortcuts, like closing the tab, can't be blocked by any web page.
key, code or keyCode: which one should you use?
event.keyis the character or the name of the key, after the keyboard layout and modifiers are applied. Shift with 2 gives@on a US layout but"on a UK layout.1 Use it for text and for shortcuts named after a letter, such as Ctrl+K. Special keys get fixed names likeEnter,EscapeorArrowUp, defined in a W3C list.2event.codeis the physical key, and it does not change with the layout or with modifiers.KeyQis the Q key on QWERTY, but the same key types A on AZERTY.3 Use it when position matters, such as WASD movement in a game.event.keyCodeandwhichare deprecated. MDN asks developers to avoidkeyCodeand to usekeyorcodeinstead.4 It still works in every browser, which is why old code and many tutorials use it, but its numbers differ between browsers for some keys.
The location value tells keys with the same name apart: 0 is a standard key, 1 is the left key (left Shift), 2 is the right key, and 3 is the numeric keypad.5
If you style your own focus and key hints in CSS, the PX to REM converter and the CSS formatter help keep that code clean.
More free tools
Robots.txt tester and generator
Robots.txt tester that runs in your browser. Check if Googlebot or any crawler may fetch a URL, see the exact rule that decides it, and build a new file.
ASCII table and converter
ASCII table with all 128 codes in decimal, hex, octal and binary, plus a converter from text to ASCII codes and back. Runs in your browser.
Image converter
Image converter that runs in your browser. Convert PNG, JPG, WebP, AVIF, GIF and SVG files in bulk, with quality and resize options. No uploads.
HTML to Markdown converter
HTML to Markdown converter that runs in your browser. Paste HTML or rich text from a web page, Google Docs or Word and get clean GitHub Markdown.
Test credit card numbers generator
Test credit card numbers for form and checkout tests, made in your browser. Generate valid-format numbers for 7 card networks and check any number.
PX to REM converter
PX to REM converter that runs in your browser. Convert px to rem and rem to px at any root font size, or convert a whole stylesheet at once.
Frequently asked questions
Sources
MDN Web Docs: KeyboardEvent: key property
MDN Web Docs: KeyboardEvent: code property
MDN Web Docs: KeyboardEvent: keyCode property
MDN Web Docs: KeyboardEvent: location property
MDN Web Docs: Element: keydown event