search

Found

info Overview

Press any key to see its key, code, keyCode, location and modifier keys. Keeps a 50-event history and a preventDefault toggle for testing shortcuts.

📘 How to Use

  1. Press any key on your keyboard.
  2. View event information such as key, code, and keyCode; each press adds a row to the history.
  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 as you press each key. Built for developers mapping shortcuts, debugging game controls, or exploring browser event handling.

💡 What This Tool Does

Stop console-logging your way through event listeners. This utility captures keystroke data with no setup: open the page and press a key.

  • Start Typing: Press any key to see the event data update.
  • Monitor Modifiers: See whether Shift, Ctrl, Alt, and Meta (Cmd/Win) are held down.
  • 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.