# How I check keyboard key codes in the browser

A beginner-friendly guide to key, code, modifier states, keyboard events, and testing shortcuts.

- Date: 2026-09-27
- URL: https://ilham.dev/posts/how-to-check-keyboard-keycodes-in-the-browser/
- Markdown: https://ilham.dev/posts/how-to-check-keyboard-keycodes-in-the-browser/index.md
- Tags: keyboard, javascript, web, tools
- Reading time: 2 min


Keyboard events expose values such as `key`, `code`, and modifier states. They are useful when building shortcuts or input handling.

The [Keycode Info](/tools/keycode-info/) tool helps with the mechanical part, but I still check the result before using it somewhere real.

## The simple idea

Keyboard events expose values such as `key`, `code`, and modifier states. They are useful when building shortcuts or input handling.

I use the tool to make the transformation visible: input on one side, output on the other, and a quick sanity check before I copy anything.

## Step 1: Open the keycode tool

Open the keycode tool.

## Step 2: Press the key combination you want to inspect

Press the key combination you want to inspect.

## Step 3: Compare `key` and `code`

Compare `key` and `code`.

## Step 4: Check Shift, Ctrl, Alt, and Meta modifier states

Check Shift, Ctrl, Alt, and Meta modifier states.

## Step 5: Test on the keyboard layout your users have

Test on the keyboard layout your users have.

## Step 6: Avoid hijacking common browser shortcuts

Avoid hijacking common browser shortcuts.

## Step 7: Provide accessible alternatives for important actions

Provide accessible alternatives for important actions.

## My checklist

Before I trust the result, I check:

- Open the keycode tool.
- Press the key combination you want to inspect.
- Compare `key` and `code`.
- Check Shift, Ctrl, Alt, and Meta modifier states.
- Test on the keyboard layout your users have.
- Avoid hijacking common browser shortcuts.
- Provide accessible alternatives for important actions.

Small utilities are useful because they remove repetitive work. They are safest when the output is still reviewed.
