Files
explicata/src/ui/press.ts
T
thalladaandClaude Opus 5.5 9b73cdb15e press() and actions.ts: what the mouse offers, from one place
press(key) sends a synthetic keydown through the page's key handler, so a
mouse control does exactly what its key does. actions.ts builds the items of
the selection bar, the ⋯ menus and the right-click menu from a context for
each kind of target (words, a node, a page, a pane, an article's row, the top
bar); each item names its key and runs by pressing it, or runs a command of
the command bar. Unit tests check every item presses its own key and that the
key handler takes that key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
2026-11-16 02:12:06 -05:00

10 lines
519 B
TypeScript

/**
* The one way a mouse control acts: it presses the key it names. A synthetic keydown goes to the
* window, where the page's key handler (keys.ts `handleKey`, listened for by App.tsx) takes it as
* it takes a real one, so a button, a menu item or the selection bar does exactly what its key does
* and no action has a second implementation.
*/
export function press(key: string, shift = false) {
window.dispatchEvent(new KeyboardEvent("keydown", { key, shiftKey: shift, bubbles: true, cancelable: true }));
}