search

Found

info Overview

Press any key to inspect key, code, keyCode, location and modifiers live. 50-event history plus preventDefault toggle.

📘 How to Use

  1. Press any key on your keyboard.
  2. View event information such as key, code, and keyCode in real-time.
  3. Enable preventDefault to suppress browser key actions (F12, etc.) while testing.

Keyboard Event Viewer

Press any key to see event details...

Shift
OFF
Ctrl
OFF
Alt
OFF
Meta / Win
OFF

History

key code which / keyCode Modifiers
Article

Debug JavaScript Keyboard Events & KeyCodes ⌨️

Inspect key, code, and which properties in real-time. Built for developers mapping shortcuts, debugging game controls, or exploring browser event handling.

🚀 High-Performance Inspection

Stop console-logging your way through event listeners. This utility provides an instant, zero-config environment to capture keystroke data.

  • Start Typing: Press any key to see event data update instantly.
  • Monitor Modifiers: Track the real-time status of Shift, Ctrl, Alt, and Meta (Cmd/Win) keys.
  • Enable preventDefault: Toggle the option to test keys like Tab, F5, or F12 without refreshing the page or shifting focus.
  • Review Input History: Access a chronological log to debug complex key sequences and event flows.

📘 Key vs. Code: The Essentials

Understanding the difference between these properties is vital for robust input handling:

  • event.key: Represents the character produced. It changes based on modifiers and keyboard layouts (e.g., "a" vs. "A"). Use this for text-entry logic.
  • event.code: Represents the physical button on the hardware (e.g., KeyQ). Use this for game controls (WASD) or layout-dependent shortcuts.

🧐 FAQ

Why is the which value 229? This typically indicates an active IME (Input Method Editor), common for Japanese or Chinese input. Disable the IME to see raw key data.

Is which still relevant? It is deprecated in favor of .key and .code. We include it specifically to help you debug legacy projects and older libraries.

How do I detect the Mac Command key? The browser identifies it as the Meta key. This tool tracks it automatically across Windows and macOS.