keys
Import
Section titled “Import”import * as api from "@fungi.computer/nacre/keys";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| type alias | ShellChord | One physical chord parsed from a Whistle binding such as alt+left. |
| type alias | KeyEventFacts | Keyboard facts shared by DOM events and terminal adapters. |
| type alias | LeaderKey | One key offered after the leader chord, with the command it runs. |
| type alias | ShellKeyHost | The shell host operations the key dispatcher reads. |
| function | parseChord() | Parse one single-chord binding. Sequences (including <leader>x) and unknown
modifiers return null; they are never matched as one chord. |
| function | chordMatches() | Whether one key event is exactly this chord. |
| function | leaderKeys() | The single-keystroke <leader>x rows, first binding per key. |
| function | leaderKeyMatches() | Whether one key event (after the leader) selects this leader key. |
| function | installShellKeys() | Dispatch the active view’s single-chord bindings from the shell document. Text entry is a mode: while an input is focused only Ctrl/Cmd chords fire, so Alt-arrows keep their word-navigation meaning. |
ShellChordtype alias
Section titled “ShellChord”type ShellChord = Readonly<{ key: string; alt: boolean; ctrl: boolean; meta: boolean; shift: boolean;}>;One physical chord parsed from a Whistle binding such as alt+left.
KeyEventFactstype alias
Section titled “KeyEventFacts”type KeyEventFacts = Pick< KeyboardEvent, "altKey" | "ctrlKey" | "key" | "metaKey" | "shiftKey">;Keyboard facts shared by DOM events and terminal adapters.
LeaderKeytype alias
Section titled “LeaderKey”type LeaderKey = WhistleBindingProjection & Readonly<{ key: string; }>;One key offered after the leader chord, with the command it runs.
ShellKeyHosttype alias
Section titled “ShellKeyHost”type ShellKeyHost = Readonly<{ active: () => WhistleSnapshot; subscribe: (listener) => () => void; execute: (commandId, input) => Promise<WhistleExecutionOutcome>;}>;The shell host operations the key dispatcher reads.
parseChord()function
Section titled “parseChord()”function parseChord( binding, mac,): Readonly<{ key: string; alt: boolean; ctrl: boolean; meta: boolean; shift: boolean;}> | null;Parse one single-chord binding. Sequences (including <leader>x) and unknown
modifiers return null; they are never matched as one chord.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
binding |
string |
mac |
boolean |
Returns
Section titled “Returns”| Readonly<{ key: string; alt: boolean; ctrl: boolean; meta:
boolean; shift: boolean; }> | null
chordMatches()function
Section titled “chordMatches()”function chordMatches(event, chord): boolean;Whether one key event is exactly this chord.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
KeyEventFacts |
chord |
ShellChord |
Returns
Section titled “Returns”boolean
leaderKeys()function
Section titled “leaderKeys()”function leaderKeys(active): readonly LeaderKey[];The single-keystroke <leader>x rows, first binding per key.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
active |
WhistleSnapshot |
Returns
Section titled “Returns”readonly LeaderKey[]
leaderKeyMatches()function
Section titled “leaderKeyMatches()”function leaderKeyMatches(event, key): boolean;Whether one key event (after the leader) selects this leader key.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
Pick<KeyboardEvent, "altKey" | "ctrlKey" | "key" | "metaKey"> |
key |
string |
Returns
Section titled “Returns”boolean
installShellKeys()function
Section titled “installShellKeys()”function installShellKeys(root, host, mac): () => void;Dispatch the active view’s single-chord bindings from the shell document. Text entry is a mode: while an input is focused only Ctrl/Cmd chords fire, so Alt-arrows keep their word-navigation meaning.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root |
HTMLElement |
host |
ShellKeyHost |
mac |
boolean |
Returns
Section titled “Returns”() => void