Skip to content

components/keyboard-layout

import { … } from 'zidane-ui'ui/src/components/keyboard-layout.ts

Functions#

_resetKeyboardLayoutFunction#

Tests: drop the cached layout (and re-request on next use), or install a fake one.

TypeScript
function _resetKeyboardLayout(next?: LayoutMapLike | null): void
Parameters
NameTypeDefaultDescription
next?LayoutMapLike | nullnull

A layout map to use instead (no request is made then); null clears it.

ui/src/components/keyboard-layout.ts:111

layoutKeyLabelFunction#

How to label spec key name on this layout: for a punctuation key whose physical key types a stand-in (typesStandIn), that character, so the keycap names exactly what the matcher accepts; otherwise name.

TypeScript
function layoutKeyLabel(name: string): string
Parameters
NameTypeDescription
namestring

A binding spec's key name ([, /, k, Enter…).

string

ui/src/components/keyboard-layout.ts:82

typesStandInFunction#

Whether key (an event.key or a layout character) stands in for the spec key at its physical position: a dead key or a single character other than printable ASCII (never a named key like Process). The one rule shared by the matcher and keycap labels.

TypeScript
function typesStandIn(key: string): boolean
Parameters
NameTypeDescription
keystring

An event.key value or a character from the layout map.

boolean

ui/src/components/keyboard-layout.ts:61

useKeyboardLayoutFunction#

Re-renders once the keyboard layout is known (for keycap labels).

TypeScript
function useKeyboardLayout(enabled?: boolean): void
Parameters
NameTypeDefaultDescription
enabled?booleantrue

false neither subscribes nor starts loading the layout.

ui/src/components/keyboard-layout.ts:102

Constants#

PUNCTUATION_CODESConstant#

Spec character → physical keys. macOS ISO keyboards swap Backquote and IntlBackslash.

TypeScript
const PUNCTUATION_CODES: Readonly<Record<string, readonly string[]>>

ui/src/components/keyboard-layout.ts:14