Skip to main content

Module keys

Module keys 

Source
Expand description

FRAME-36: keys — a component’s shortcuts, the host’s to handle.

A component declares them (rhx: keys(#{ "ctrl+k": "open", … }), the tree’s keys; a module: bus.keys({ … })); the host keeps one registry per page (Keys, on the crate::bus::Bus) and listens on the window in the capture phase. A press that matches is the host’s alone: the listener calls preventDefault(), stopPropagation() and stopImmediatePropagation() before anything else hears it, then runs what it names. A component’s entries go when it leaves the bus (destroy, swap) — nothing outlives it.

  • A chord is [ctrl+][alt+][shift+][meta+]key, key the event’s KeyboardEvent.key lower-cased (" " is space); shift is said only with a letter or a named key — a character shift makes (?) carries it. A sequence is chords separated by a space, each within SEQUENCE_MS of the one before.
  • An editable target (input, textarea, select, contenteditable) is skipped unless the entry says in_inputs or its chord holds ctrl or meta. FRAME-38: plain enter and space on an activatable target (a button, a link, a summary, [role=button]) are skipped unless the entry says in_controls — the press still clicks.
  • Two entries on one press both run, the last registered (the deeper, mounted later) first; an entry that says only runs alone — the first such in that order.
  • ?, when nothing binds it and anything is registered, toggles the overlay of every registered key, grouped by component; escape closes it; an autorepeated ? toggles nothing. FRAME-38: the overlay follows the registry — redrawn on every change while open, closed when it empties (Keys::on_change).

Pure: the DOM’s listener (tree::dom) turns a KeyboardEvent into a Press and asks Keys::press; the native tests ask it directly.

Structs§

KeyDecl
One declaration: the sequence, what it runs (a fold’s name, or a module’s function’s), its label, and its two switches.
Keys
The page’s keys (a handle: clones are the same registry).
KeysHeld
Entries held: dropping it takes them out.
Press
One key press, as the window heard it.

Enums§

Heard
What Keys::press did with a press.

Constants§

NAMED
The named keys a chord may end in (the compiler’s list, plexus_ui_compiler::keys::NAMED).
RESERVED
EDITOR-13: the chords the browser keeps — no page ever hears them, so binding one is refused: ctrl or meta (with shift or not, never alt) and t, w, n or tab. The compiler’s and the engine’s lists, byte for byte.
SEQUENCE_MS
How long the next chord of a sequence may wait, in milliseconds.

Functions§

chord
One declared chord, canonical — the modifiers in the order ctrl, alt, shift, meta; or why it is not one. FRAME-38: a chord is lower case — an upper-case letter (K: shift+k, or k?) is refused. The compiler’s twin, byte for byte.
event_chord
The chord a KeyboardEvent is — its key and modifiers — or none for a modifier alone (or a dead key, or a composition’s).
hides
FRAME-38: a hides b — a chord (or sequence) bound alone that b begins with, so b could never be pressed.
reserved
Why a chord (its modifiers held, its key) is the browser’s, or none.
sequence
A declared sequence: its chords, canonical.

Type Aliases§

KeyGroups
The overlay’s rows: per component (in the order they registered), each (chord, what it shows).
KeyRun
What runs on a match: handed { key, chord, target }.