Skip to main content
WEB DEVELOPMENT TOOL
⌨️

JavaScript KeyCode Finder

Press any physical key on your keyboard to instantly inspect its event.key, event.code, legacy event.which / keyCode values, modifier states, and event listeners.

✓Runs 100% locally in your browser
✓Zero keylogging or background telemetry
✓Vanilla JS & React useEffect snippet generation

Detects keyboard layout differences, function keys, media keys, and numpad codes.

13
event.key: "Enter"
event.code: Enter
Live Event InspectorListening for keystrokes...
event.keyEnter
event.codeEnter
event.which / keyCode13
event.locationStandard (DOM_KEY_LOCATION_STANDARD)
Ctrl: FALSEShift: FALSEAlt: FALSEMeta / Cmd: FALSE
Vanilla JavaScript Listener
// Vanilla JavaScript Keyboard Listener
window.addEventListener('keydown', (e) => {
  if (e.code === 'Enter') {
    console.log('Pressed Enter [Enter]');
    // Your logic here
  }
});
React useEffect Hook
// React useEffect Keyboard Listener
import { useEffect } from 'react';

export function useKeyAction() {
  useEffect(() => {
    const handleKeyDown = (e: KeyboardEvent) => {
      if (e.code === 'Enter') {
        console.log('Triggered Enter');
      }
    };
    window.addEventListener('keydown', handleKeyDown);
    return () => window.removeEventListener('keydown', handleKeyDown);
  }, []);
}

Interactive JavaScript Keyboard Event Inspector

Handling keyboard shortcuts, game controls, and navigation accessibility requires precise knowledge of keyboard event properties across different operating systems and physical keyboard layouts.

The JavaScript KeyCode Finder listens to keydown events in real time, displaying modern standard properties (event.key, event.code) alongside legacy numeric codes (event.keyCode, event.which), key locations, modifier states, and ready-to-use event listener snippets.

Core Tool Capabilities

  • Real-Time Keystroke Capture: Captures and analyzes keydown events instantaneously with full property breakdown.
  • Modern & Legacy Codes: Displays standard event.key, event.code as well as legacy numeric keyCode and which identifiers.
  • Modifier State Detection: Tracks active status for Shift, Control, Alt/Option, and Meta/Command modifier keys.
  • Snippet Code Generation: Produces clean vanilla JavaScript event listeners and React useEffect hooks.

Local Browser Privacy

Your files are processed locally on your device. Files are not uploaded, transmitted, or stored on remote servers.

Once the page has loaded, you can disconnect your network connection and continue using this tool offline.

Target Use Cases

  • • Building Keyboard Shortcuts
  • • Web Game Controls
  • • Accessible Form Navigation
  • • Cross-Platform Keyboard Testing

Technical Specifications & Platform Limits

Standards Compliance
W3C UI Events Specification

Supports event.key, event.code, and DOM_KEY_LOCATION constants

Event Listeners
Vanilla JS & React Hook

One-click copyable listener templates

Keystroke History
10 Recent Key Events

Instant replay and inspection of previous keystrokes

Privacy
Local Browser Event Loop

Keystrokes are never transmitted or stored externally

Step-by-Step Workflow

1

Press Any Key

Press any physical or virtual key on your keyboard while viewing this page.

2

Inspect Event Properties

Examine event.key, event.code, legacy numeric keyCode, and location in real time.

3

Check Active Modifiers

Observe active states for Ctrl, Shift, Alt, and Meta keys.

4

Copy Code Snippet

Copy the generated vanilla JS listener or React useEffect hook into your project.

Practical Real-World Use Cases

Building Keyboard Shortcuts

Determine exact key codes and identifiers for application hotkeys and accelerators.

Web Game Controls

Inspect physical key locations (WASD, Arrow keys, Numpad) for responsive gaming inputs.

Accessible Form Navigation

Implement accessible keyboard interactions (Enter, Space, Escape, Tab) for modals and dropdowns.

Cross-Platform Keyboard Testing

Verify key event differences between Mac Command, Windows Ctrl, and international keyboards.

Frequently Asked Questions

Why is event.keyCode deprecated in modern web standards?
The W3C deprecated event.keyCode because numeric codes vary between keyboard layouts and operating systems. Developers should prefer event.key (for characters) and event.code (for physical key locations).
What is the difference between event.key and event.code?
event.key represents the character value produced (taking into account Shift or CapsLock, e.g. 'A' vs 'a'), while event.code represents the physical key position on the keyboard (e.g. 'KeyA').
What does event.location mean?
event.location indicates where the key is located on the keyboard: 0 for Standard, 1 for Left (e.g. Left Shift), 2 for Right (e.g. Right Shift), and 3 for Numpad.
Are my keystrokes logged or transmitted?
No. Key events are handled strictly in local browser memory and never leave your device.

Share this tool

Help others discover this utility. No login or registration required.