lib/keyboard-layout
Best-effort detection of the client's physical keyboard layout for the
SETTINGS keyboardLayout hint, as xkb layout names.
Chromium exposes navigator.keyboard.getLayoutMap(), and a handful of
probe keys identify the layout family (KeyY producing z is QWERTZ,
KeyQ producing a is AZERTY, ...). Everywhere else, and when the probes
are inconclusive, the BCP 47 navigator.language tag maps language and
region to a layout. Both resolve to null when unknown, and callers omit
the hint then.
Functions
layoutFromLanguage()
function layoutFromLanguage(lang): string;Defined in: lib/keyboard-layout.js:44
Maps a BCP 47 language tag to an xkb layout name.
Parameters
| Parameter | Type | Description |
|---|---|---|
lang | string | A tag such as en-GB or de. |
Returns
string
The layout, or null when the tag names none.
detectKeyboardLayout()
function detectKeyboardLayout(): Promise<string>;Defined in: lib/keyboard-layout.js:59
Detects the physical layout through the keyboard layout map where the engine exposes one, falling back to the language tag.
Returns
Promise<string>
The xkb layout name, or null when unknown.