---
title: "Meta Key Code: keyCode 91, 92, 93 (Windows Key and Cmd)"
description: "Windows key and Mac Cmd send event.key \"Meta\", event.code \"MetaLeft\" or \"MetaRight\", and keyCode 91, 92, 93 or 224 by browser. Cmd shortcuts, lost keyups."
url: https://devicetests.com/keycode/meta
language: en
---

# Meta key code (Windows key and Command)

The Windows key and Cmd send event.key "Meta". keyCode is 91 for the left key, but the right key and Firefox on a Mac differ.

## Every value at a glance

| Key | event.code | event.key | keyCode | keyCode on a Mac | event.location |
| - | - | - | - | - | - |
| Left Windows / Left Command | `MetaLeft` | `Meta` | 91 | | 1 (Left side) |
| Right Windows / Right Command | `MetaRight` | `Meta` | 92 | 93 | 2 (Right side) |

keyCode as Chrome and Edge send it on Windows. The Mac column (Chrome and Safari on a Mac) and the Firefox column show only numbers that differ; some keys also differ by system, as the text below says. event.which is always the same number as keyCode. event.key is for a US layout without Shift.

## Code to react to Left Windows

Recommended: match event.key

```
document.addEventListener('keydown', (event) => {
  if (event.key === 'Meta') {
    // Your code here
  }
});
```

Match the key's place: event.code

```
document.addEventListener('keydown', (event) => {
  if (event.code === 'MetaLeft') {
    // Your code here
  }
});
```

Old code that still uses keyCode (deprecated)

```
document.addEventListener('keydown', (event) => {
  if (event.keyCode === 91) {
    // Your code here
  }
});
```

## Which value to use

For Mac shortcuts, check `event.metaKey` on the other key’s keydown. It is true while Cmd (or the Windows key) is held. Combine it with `ctrlKey` for shortcuts that should work on both systems.

To react to the key itself, check `event.key === 'Meta'`, or `event.code`: `MetaLeft` or `MetaRight`. The same names cover the Windows key, the Mac command key and the Super key on Linux.

Don’t use keyCode for this key. The left key is 91, but Firefox on a Mac sends 224 for both keys, Firefox on Windows and Linux sends 91 for both, and the right key is 92 on Windows but 93 in Chrome and Safari on a Mac.

## What trips people up

### On a Mac, keyup never comes for keys pressed with Cmd held

macOS doesn’t send the keyup of keys pressed while Cmd is held: press Cmd + K, release K, and the page gets no keyup for K. Browsers can’t fully fix it, because macOS doesn’t report the release. Don’t track held keys through Cmd shortcuts. When the Meta keyup arrives, mark the keys pressed while Cmd was held as released.

### keyCode 93 means two different keys

On Windows, 93 is the menu key (`event.code` “ContextMenu”). In Chrome and Safari on a Mac, 93 is the right Cmd key. Use `event.code` to know which one you got.

### The Windows key opens the Start menu instead

The Windows key on its own opens Start, and Windows shortcuts such as Windows + D, Windows + L or Windows + Tab go to the system. The page can’t stop them. Start takes the focus, so keyups can go missing: reset held keys on the window’s `blur` event. Don’t build shortcuts on the Windows key.

### Old Firefox sends “OS” and “OSLeft”

Firefox before version 118 sent `event.key` “OS” for the Windows key and `event.code` “OSLeft” and “OSRight”. Chrome used “OSLeft” and “OSRight” before version 52. Current browsers send `"Meta"`, `"MetaLeft"` and `"MetaRight"`. Check the old names only if you support those versions.

## Cmd shortcuts on a Mac

Mac users expect Cmd where Windows uses Ctrl: Cmd + S to save, Cmd + Z to undo, Cmd + Shift + Z to redo. Accept `event.ctrlKey || event.metaKey`, and label the shortcut Cmd + S or ⌘S on a Mac. Cmd + N, Cmd + T, Cmd + W and Cmd + Q belong to the browser and never reach the page.

## Related keys

- [Control key code](https://devicetests.com/keycode/control)
- [Alt key code](https://devicetests.com/keycode/alt)
- [Shift key code](https://devicetests.com/keycode/shift)
- [Function key codes (F1–F24)](https://devicetests.com/keycode/function-keys)
- [Keycode finder: press any key to see its codes](https://devicetests.com/keycode)
- [All key codes in one table](https://devicetests.com/keycode#key-codes)
