normalizeKey

Commons
stable

Normalises a keyboard key string to its canonical lowercase form using the internal alias map. Aliases such as "esc", "escape", "up", "arrowup" are all resolved to a single canonical name.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

key
required
string
A raw key string from a KeyboardEvent (e.g. "Escape", "ArrowUp", "Enter"). Case-insensitive.

API

Return value

The value returned by this util.

The canonical lowercase key name after alias resolution. Unrecognised keys are returned lowercased as-is.

Usage

Examples

Ready-to-paste usage snippets.

Resolve keyboard aliases

typescript