@pyreon/hotkeys 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +64 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @pyreon/hotkeys
2
+
3
+ Reactive keyboard shortcut management for Pyreon. Scope-aware, modifier keys, conflict detection, automatic lifecycle cleanup.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @pyreon/hotkeys
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ import { useHotkey, useHotkeyScope } from '@pyreon/hotkeys'
15
+
16
+ // Global shortcut — auto-unregisters on unmount
17
+ useHotkey('mod+s', () => save(), { description: 'Save document' })
18
+ useHotkey('mod+k', () => openCommandPalette())
19
+
20
+ // Scoped shortcuts — only active when scope is enabled
21
+ useHotkeyScope('editor')
22
+ useHotkey('ctrl+z', () => undo(), { scope: 'editor' })
23
+ useHotkey('escape', () => closeModal(), { scope: 'modal' })
24
+ ```
25
+
26
+ `mod` = Command on Mac, Ctrl elsewhere. Shortcuts are ignored in input elements by default.
27
+
28
+ ## API
29
+
30
+ ### `useHotkey(shortcut, handler, options?)`
31
+
32
+ Component-scoped keyboard shortcut. Automatically unregisters on unmount.
33
+
34
+ Options: `scope`, `description`, `preventDefault` (default: true), `enableInInputs` (default: false).
35
+
36
+ ### `useHotkeyScope(scope)`
37
+
38
+ Activate a scope for the component's lifetime. Deactivates on unmount.
39
+
40
+ ### `registerHotkey(shortcut, handler, options?)`
41
+
42
+ Imperative registration. Returns an unregister function.
43
+
44
+ ### `enableScope(scope)` / `disableScope(scope)`
45
+
46
+ Manually control which scopes are active.
47
+
48
+ ### `getRegisteredHotkeys()`
49
+
50
+ List all registered hotkeys — useful for help dialogs.
51
+
52
+ ### `getActiveScopes()`
53
+
54
+ List currently active scopes.
55
+
56
+ ### Utilities
57
+
58
+ - `parseShortcut(str)` — parse shortcut string into `KeyCombo`
59
+ - `formatCombo(combo)` — format `KeyCombo` as display string
60
+ - `matchesCombo(event, combo)` — check if a keyboard event matches a combo
61
+
62
+ ## License
63
+
64
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/hotkeys",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Reactive keyboard shortcut management for Pyreon — scope-aware, conflict detection",
5
5
  "license": "MIT",
6
6
  "repository": {