The JS Keycode Finder on FreeToolZones shows you exactly what your browser reports when you press a key: the key value, the physical code, the legacy numeric codes, the key location, and any modifier keys held at the same time. Keyboard handling is one of those areas where guessing leads to bugs. Different keyboards, layouts, and browsers can report the same physical key in subtly different ways, and the only reliable way to know what your code will receive is to press the key and look at the event. This tool gives you that view instantly, with a live display, a detail grid, and a history of the keys you pressed.
Whether you are building a keyboard shortcut, a game control scheme, an accessible widget, or a text editor feature, you need the real event values, not values remembered from a table that may be out of date. Pressing a key here shows you the values for your own keyboard, your own layout, and your own browser, which is precisely the combination your users may or may not share. That is why a live finder beats a static reference: it answers the question for the hardware in front of you, right now.
What Is the JS Keycode Finder?
The JS Keycode Finder is a free online tool that captures keydown events and displays their properties. The page has a large display that shows the key you just pressed, a capture box you click to focus, an optional mode that listens for keys anywhere on the page, a grid of six detail values, and a table of recent keys. There is nothing to type and nothing to submit: you press keys, and the tool reports what the browser saw.
The six detail values are Key, Code, keyCode, Which, Location, and Modifiers. Key is the value of the key that was pressed, such as a letter, a digit, or a named key like Enter or ArrowLeft. It reflects the character produced, so it depends on the keyboard layout and on modifiers like Shift. Code is the physical key identifier, such as KeyA or Digit1, which identifies the position of the key rather than the character it produces, so it stays the same across layouts. The keyCode and which values are the legacy numeric codes that older code relied on. Location tells you which version of a key was pressed, using the names Standard, Left, Right, or Numpad. Modifiers lists the modifier keys held down, using the names Ctrl, Alt, Shift, and Meta, plus Repeat when the event came from holding a key down.
The page carries an important note about the legacy values: keyCode and which are shown for compatibility with older code, but both are deprecated, and modern code should use event.key and event.code instead. That guidance reflects the direction of the web platform. The numeric codes were never fully consistent across browsers and layouts, and the newer string properties are clearer, more predictable, and self-describing. The tool shows the old values because developers maintaining older code still need them, but new code should be written against key and code.
The history table keeps the twelve most recent key presses, newest first, with columns for Key, Code, keyCode, and Modifiers. It is useful when you are comparing several keys, checking a sequence, or noting down values for a shortcut combination. A Clear history button resets the history, the display, and the detail grid in one step, returning the tool to its starting state with the display reading Press any key.
How to Use the JS Keycode Finder
Using the tool is a matter of focusing the capture area and pressing keys. Follow the steps below for the most reliable results.
- Click the capture box. The box labeled Key capture box is the focused listening area. Click inside it so it has keyboard focus. The box text explains that Tab and Space are captured while the box is focused, which matters because those keys normally move focus or scroll the page instead of reaching your handler.
- Press any key. The large display updates to show the key, with the space bar shown as the word Space so it is visible. The detail grid fills in with the Key, Code, keyCode, Which, Location, and Modifiers values for that press, and the press is added to the Recent keys table.
- Try modifier combinations. Hold Ctrl, Alt, Shift, or Meta while pressing another key, and watch the Modifiers cell. Try holding a key down to see Repeat appear. Try the left and right versions of Shift, Ctrl, and Alt to see the Location cell change between Left and Right. Try numpad keys to see the Numpad location.
- Use page-wide listening if needed. Tick the checkbox labeled Listen for keys anywhere on this page if you want key presses captured no matter which part of the page has focus. Unticking it returns listening to the capture box only. Page-wide mode is convenient, but be aware that keys pressed while typing in another field will also be captured.
- Read the history and clear when done. The Recent keys table keeps up to twelve entries. Use it to compare keys or to copy values into your code. Press Clear history when you want a fresh start.
A few practical notes will save confusion. The tool listens for keydown events, which fire when a key is pressed down, not when it is released. Holding a key down produces repeated keydown events, and the tool marks those with Repeat in the modifiers list. Some keys and combinations are reserved by the browser or the operating system, such as the shortcuts that switch tabs or open menus, and those may never reach the page at all. If a key produces no result here, it probably cannot be captured by web page code in your environment either, which is itself useful information when you are choosing shortcuts.
Key Features of the JS Keycode Finder
The tool is built around live capture, and its features all serve the goal of showing real event data clearly.
Live key display
The large display shows the most recent key in big, readable text, with the space bar rendered as the word Space. It is the first thing you look at after a press, and it answers the simplest question, which key did the browser think I pressed, before you look at the details.
Focused capture box with Tab and Space handling
The capture box is focusable, and while it has focus, Tab and Space are captured instead of performing their default actions. That makes it possible to inspect exactly those keys, which are otherwise hard to test because pressing Tab moves focus away and pressing Space scrolls. Clicking the box first is the key step; without focus, the box cannot capture anything.
Optional page-wide listening
The checkbox switches listening from the box to the whole document. In page-wide mode, any keydown on the page is reported, wherever focus sits. Switching back restores box-only listening. The two modes cover both careful single-key testing and quick exploration.
Six-value detail grid
Key, Code, keyCode, Which, Location, and Modifiers are shown together, so you can compare the modern string properties with the legacy numeric ones for the same press. Before any key is pressed, each cell shows a dash, which makes it obvious that no data has been captured yet.
Twelve-entry history and clear button
The Recent keys table records the last twelve presses, newest first, so you can review a sequence or compare related keys without re-pressing them. Clear history empties the table and resets the display and grid together.
Practical Use Cases
Keyboard event values matter in more places than most developers expect. The examples below show where live values beat memory and tables.
Designing keyboard shortcuts
When you add a shortcut such as Ctrl plus S or Ctrl plus Shift plus P, you need to know the exact key and code values the browser reports for that combination, including which modifier names appear. Pressing the combination here shows you all of it, and lets you confirm that the combination reaches the page at all rather than being claimed by the browser. That confirmation saves a debugging session later.
Building game controls
Games usually care about physical keys, not characters, because a player using a different layout still expects the same physical key to move or jump. The Code value is the right property for that, and this tool shows it for every key you press, including arrows, the space bar, and letter keys. Checking the code values for your control scheme on your own keyboard is the fastest way to write correct handling.
Debugging layout-dependent behavior
A user reports that a shortcut works for some people and not others. One likely cause is a layout difference: the Key value changes with layout, while the Code value does not. Comparing the two values here, and asking the user to do the same, often identifies the cause in minutes. The fix is usually to switch the handler from key to code, or vice versa, depending on what the feature actually needs.
Maintaining older code that uses keyCode
Legacy code often compares event.keyCode or event.which against numbers. When you need to extend or fix such code, you need the numeric values for the keys involved, and this tool shows them alongside the modern properties. You can also use the comparison to plan a migration: note the key and code values now, and replace the numeric checks with string checks when you refactor.
Testing accessibility features
Accessible widgets rely on keyboard interaction: Tab to move, Enter or Space to activate, arrows to move within a group, Escape to close. Pressing those keys here confirms the values your handlers will receive, including the special handling for Tab and Space, and helps you verify that focus management and key handling work together as intended.
Tips and Best Practices
- Write new code with key and code. Use event.key when you care about the character or the named key, and event.code when you care about the physical key. Avoid keyCode and which in new code, since both are deprecated.
- Choose key or code deliberately. A shortcut for a character, such as typing a letter, usually wants key. A control for a physical position, such as a game key, usually wants code. Mixing them up is a common source of layout bugs.
- Test with the modifiers your users will use. Check combinations with Shift, Ctrl, Alt, and Meta, and check both sides of the modifier keys. Location differences can matter for games and for shortcuts that distinguish left and right modifiers.
- Remember that some keys never reach the page. Browser and operating system shortcuts take priority. If a combination produces nothing here, do not build a feature that depends on it.
- Handle key repeats intentionally. Holding a key down sends repeated events. Decide whether your handler should act on every repeat or only on the first press, and use the repeat information to implement that decision.
- Do not hard-code numbers from memory. Press the key here and read the actual values. Memory and old tables are unreliable, and the cost of checking is one key press.
Limitations
The finder shows what your browser reports on your keyboard and layout, and those values can differ on other machines. A key that reports one value here may report a different Key value on another layout, and some keys exist only on certain keyboards. The tool cannot show values for keys your hardware does not have, and it cannot override browser or operating system shortcuts that consume a key before the page sees it. The history holds twelve entries, so longer sequences scroll off the top, and the tool reports keydown events only: it does not show keyup or keypress behavior, and it does not simulate events.
The legacy numeric values deserve a final caution. They are shown for compatibility, but they are deprecated and their exact numbers have varied across browsers in the past. Treat them as reference data for maintaining old code, not as a foundation for new features. For new work, the Key and Code values in the same grid are the values to build on.
Frequently Asked Questions
What is the difference between Key and Code?
Key is the character or named key produced by the press, and it depends on the layout and modifiers. Code identifies the physical key by position, and it stays the same across layouts. Use key when the character matters and code when the physical position matters.
Why are keyCode and which still shown if they are deprecated?
Because older code still uses them, and developers maintaining that code need the numeric values. The page advises modern code to use event.key and event.code instead, and you should follow that advice for anything new.
Why does pressing Tab not show a result sometimes?
Tab normally moves focus, so it only reaches the capture handler when the capture box has focus, where its default action is prevented. Click the box first, then press Tab. In page-wide mode, Tab may move focus before the handler reports it, depending on the browser.
What do the Location values mean?
Standard means an ordinary key, Left and Right distinguish the two copies of modifier keys and similar duplicated keys, and Numpad means a key on the numeric keypad. The value comes from the event location property reported by the browser.
Why does holding a key add Repeat to the modifiers?
Holding a key down generates repeated keydown events, and the browser marks the repeats. The tool shows Repeat alongside any modifiers held, so you can tell a held key apart from separate presses.
Can I test keys that my browser reserves?
Not reliably. Shortcuts claimed by the browser or operating system may never reach the page. If a key produces no result here, assume web page code cannot depend on it in your environment.
Related Tools
These tools help you write, check, and test the keyboard handling code that uses the values this finder shows.
- JS Snippet Tester – try out a keydown handler in a sandboxed frame and watch its console output.
- JavaScript Validator – check the syntax of your handler code without running it.
- JS String Escaper – build string literals safely when your handler compares key values.
- HTML Code Tester – test a page that combines markup with keyboard interaction.
- Online HTML Editor – build a small test page around the keyboard feature you are developing.