Keyboard Event Keycode Viewer

Find out exactly what your keyboard sends to a web page, including the physical key code, the character and the deprecated numeric codes old scripts still use.

ทำงานในเบราว์เซอร์ของคุณ ไฟล์ไม่ออกจากอุปกรณ์ ดูวิธีตรวจสอบ

…

วิธีทำ

  1. 1
    Click the box

    It must have focus.

  2. 2
    Press a key

    Or a combination.

  3. 3
    Read the values

    key, code, keyCode, location.

  4. 4
    Check the log

    keydown and keyup in order.

  5. 5
    Search the table

    For codes you need in code.

  6. 6
    Update old code

    Replace keyCode with key or code.

เกี่ยวกับเครื่องมือนี้

Keyboard handling is one of the messiest corners of web development. A shortcut that works on a US keyboard fails on a French AZERTY layout, a game's WASD controls move the wrong way in Germany, the numeric keypad's Enter key needs separate handling, and old code still compares numbers like 13 and 27 that modern specifications have deprecated. This viewer shows what the browser really reports. Click the box and press any key: it displays event.key, the character or named key produced with the current layout, event.code, the physical key position, the legacy keyCode, the location (standard, left, right or numpad), the modifier keys held and whether the key is auto-repeating. A running log records keydown and keyup events so you can see sequences and combinations. Below, a searchable reference table lists key, code and keyCode values for a US layout, from letters, digits and function keys to arrows, the numeric keypad and punctuation, which helps when reading or updating older code.

key, code and keyCode

- event.key is what the key means: a for the A key, A with Shift, q on an AZERTY keyboard pressing the same physical key, or names such as Enter and ArrowLeft. Use it for text and most shortcuts. - event.code is where the key is: KeyA is always the key right of Caps Lock on a US layout, whatever it types. Use it for games and position-based shortcuts. - keyCode and which are older numeric values. They are deprecated, differ between browsers for some keys and do not describe layouts properly. Avoid them in new code.

Modifiers and location

Shift, Control, Alt and Meta (Command on Mac, Windows key on PC) appear as properties on every event. The location property separates left and right modifiers and the numeric keypad, so you can tell Numpad Enter from the main Enter key.

Keys the page never sees

Some combinations are handled by the operating system or the browser before the page receives them: closing a tab, switching windows, taking screenshots or opening the task manager. Do not build features that depend on them.

Input method editors

When people type Chinese, Japanese or Korean with an input method, keydown events fire with isComposing set and key reported as Process. Listen to input and composition events instead of keydown for text entry.

Accessibility

Keyboard shortcuts must not override assistive technology or browser defaults, should be documented, and ideally can be turned off or remapped, as WCAG success criterion 2.1.4 requires for single-character shortcuts.

Limits

The reference table describes a US QWERTY layout. On other layouts event.key differs while event.code stays the same, which is exactly what the live viewer shows.

ตัวอย่างพร้อมวิธีทำ

Pressing Shift and the A key shows event.key A, event.code KeyA, keyCode 65, location standard and modifiers Shift; pressing the numeric keypad's Enter key shows key Enter, code NumpadEnter and location numpad.

สรุปสั้น ๆ

คำถามที่พบบ่อย

Should I use key or code?

Use key for characters and most shortcuts; use code for physical positions such as game controls.

Is keyCode deprecated?

Yes. It still works but is inconsistent; use key or code instead.

Why doesn't Ctrl+W show up?

The browser handles it before the page sees it.

How do I tell left and right Shift apart?

Check event.code (ShiftLeft or ShiftRight) or event.location.

Why is key Process?

An input method editor is composing text.

Is anything I type recorded?

No. Events stay in this page and are not sent anywhere.

ฟรีทั้งหมดไม่มีค่าใช้จ่าย ไม่ต้องสมัคร
ไฟล์เป็นส่วนตัวทุกอย่างทำงานในเบราว์เซอร์ของคุณ
ใช้ง่ายในภาษาของคุณมีหลายภาษา