Skip to content

normalizeKeyName

ts
function normalizeKeyName(key): string;

Defined in: constants.ts:248

Normalizes a key name from a KeyboardEvent or a hotkey: single letters become uppercase, and the space character becomes Space. Other names are returned as written, because key names are case-sensitive.

Parameters

key

string

The key name to normalize

Returns

string

The canonical key name

Example

ts
normalizeKeyName('a') // 'A'
normalizeKeyName(' ') // 'Space'
normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)