Builder for generate typesafe hotkey context that allow to bind keystroke to action
Implement as builder to allow generate hotkey context for platforms with different keycodes
- web browsers
- system wide keybindings for node/bun
Hotkey context split from keyPressHandler implementation cause it allow to implement keyPressHandler for multiple different scopes
ex. bind hotkeys to focused html element
<input use:handleHotkey={context().add((h) => h.enter.bind(search))} />
ex. bind to interactive element
<button use:hotkey={(h) => h.enter}>Search</button>
<input use:hotkey={(h) => h.control.keyK}>Search box</input>
const hotkeys = context()
.add((h) => h.alt.keyH.bind(() => console.log('hello world')))
.add((h) => h.alt.f4.bind(() => console.log('goodbye')))