Skip to content

normalizeKey

normalizeKey(key): string

Defined in: extensions/commands/utils.ts:27

Normalizes modifier keys to a bitmask that’s used by getKeysFromEvent. All keys are case insensitive.

Rules:

  • alt → 1
  • ctrl or control → 2
  • meta or cmd → 4
  • shift → 8
  • mod → 4 on Mac, 2 otherwise

string

Key to normalize.

string

Normalized and lowercase key.

normalizeKey("a") // "0+a"
normalizeKey("+") // "0++"
normalizeKey("ctrl+alt+a") // "3+a"
normalizeKey("10+ALT+a") // "11+a"
normalizeKey("shift+alt+12+a") // "13+a"