@tanstack/hotkeys-devtools 0.0.2 → 0.1.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.
- package/README.md +14 -82
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="./media/
|
|
2
|
+
<img src="./media/header_hotkeys.png" alt="TanStack Hotkeys" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<br />
|
|
@@ -36,54 +36,15 @@
|
|
|
36
36
|
|
|
37
37
|
# TanStack Hotkeys
|
|
38
38
|
|
|
39
|
-
Type-safe keyboard shortcuts for the web. Template strings, parsed objects, cross-platform `Mod`, a singleton Hotkey Manager, and utilities for cheatsheet UIs. Built to stay SSR-friendly.
|
|
40
|
-
|
|
41
39
|
> [!NOTE]
|
|
42
40
|
> TanStack Hotkeys is pre-alpha (prototyping phase). We are actively developing the library and are open to feedback and contributions.
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- **Options**
|
|
51
|
-
- `keydown` / `keyup` via `eventType`
|
|
52
|
-
- `preventDefault`, `stopPropagation`
|
|
53
|
-
- Conditional `enabled` to turn hotkeys on or off
|
|
54
|
-
- `requireReset`: trigger once until all keys are released
|
|
55
|
-
- **Cross-Platform Mod**
|
|
56
|
-
- `Mod` maps to **Cmd (Meta)** on macOS and **Ctrl** on Windows/Linux
|
|
57
|
-
- **Singleton Hotkey Manager**
|
|
58
|
-
- `getHotkeyManager()`, `HotkeyManager.getInstance()` to register global keyboard shortcuts
|
|
59
|
-
- Single shared listener for efficiency
|
|
60
|
-
- **Display Utilities**
|
|
61
|
-
- `formatForDisplay(hotkey)` for cheatsheet UIs (symbols on Mac, labels on Windows/Linux)
|
|
62
|
-
- `formatWithLabels`, `formatHotkey` for flexible output
|
|
63
|
-
- **Validation & Matching**
|
|
64
|
-
- `validateHotkey`, `assertValidHotkey`, `checkHotkey` for correctness validation
|
|
65
|
-
- `matchesKeyboardEvent`, `createHotkeyHandler`, `createMultiHotkeyHandler`
|
|
66
|
-
- **Sequences**
|
|
67
|
-
- `SequenceManager`, `createSequenceMatcher` for Vim-style multi-key shortcuts (e.g. `['G','G']`, `['D','I','W']`)
|
|
68
|
-
- **Key State**
|
|
69
|
-
- `KeyStateTracker`, `getKeyStateTracker` for held-key tracking
|
|
70
|
-
- **Hotkey Recorder**
|
|
71
|
-
- `HotkeyRecorder` class for capturing keyboard shortcuts interactively
|
|
72
|
-
- Supports live preview, cancellation, and clearing during recording
|
|
73
|
-
- **React Hooks**
|
|
74
|
-
- `useHotkey` – register a keyboard shortcut (global, via singleton manager)
|
|
75
|
-
- `useHotkeySequence` – detect keys pressed in order within a timeout
|
|
76
|
-
- `useHeldKeys` – reactive list of currently held keys
|
|
77
|
-
- `useKeyHold` – reactive boolean for whether a given key is held
|
|
78
|
-
- `useHotkeyRecorder` – record keyboard shortcuts interactively with live preview
|
|
79
|
-
- **Devtools**
|
|
80
|
-
- Devtools are a core focus: visibility into all registered hotkeys, scopes, and options
|
|
81
|
-
- `@tanstack/hotkeys-devtools` and `@tanstack/react-hotkeys-devtools` (in active development)
|
|
82
|
-
- **Planned**
|
|
83
|
-
- Scoping hotkeys to a DOM element or React ref
|
|
84
|
-
- Warn/error on conflicting shortcuts (TBD)
|
|
85
|
-
- Ignore hotkeys when certain inputs are focused (e.g. `input`, `textarea`)
|
|
86
|
-
- Focus traps and tab-order utilities
|
|
42
|
+
Type-safe keyboard shortcuts for the web. Template-string bindings, parsed objects, a cross-platform `Mod` key, a singleton Hotkey Manager, and utilities for cheatsheet UIs—built to stay SSR-friendly.
|
|
43
|
+
|
|
44
|
+
- Type-safe bindings — template strings (`Mod+Shift+S`, `Escape`) or parsed objects for full control
|
|
45
|
+
- Flexible options — `keydown`/`keyup`, `preventDefault`, `stopPropagation`, conditional enabled, `requireReset`
|
|
46
|
+
- Cross-platform Mod — maps to Cmd on macOS and Ctrl on Windows/Linux
|
|
47
|
+
- Batteries included — validation + matching, sequences (Vim-style), key-state tracking, recorder UI helpers, React hooks, and devtools (in progress)
|
|
87
48
|
|
|
88
49
|
### <a href="https://tanstack.com/hotkeys">Read the docs →</a>
|
|
89
50
|
|
|
@@ -98,37 +59,6 @@ Type-safe keyboard shortcuts for the web. Template strings, parsed objects, cros
|
|
|
98
59
|
> - Svelte Hotkeys – needs a contributor!
|
|
99
60
|
> - Vue Hotkeys – needs a contributor!
|
|
100
61
|
|
|
101
|
-
## Quick Example
|
|
102
|
-
|
|
103
|
-
```tsx
|
|
104
|
-
import { useHotkey, formatForDisplay } from '@tanstack/react-hotkeys'
|
|
105
|
-
|
|
106
|
-
function Editor() {
|
|
107
|
-
useHotkey(
|
|
108
|
-
'Mod+S',
|
|
109
|
-
(e, { hotkey }) => {
|
|
110
|
-
save()
|
|
111
|
-
},
|
|
112
|
-
{ requireReset: true },
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<div>
|
|
117
|
-
<button>Save</button>
|
|
118
|
-
<span>{formatForDisplay('Mod+S')}</span>{' '}
|
|
119
|
-
{/* e.g. "⌘S" on Mac, "Ctrl+S" on Windows */}
|
|
120
|
-
</div>
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## Packages
|
|
126
|
-
|
|
127
|
-
- **`@tanstack/hotkeys`** – Core: parse, format, match, validate, manager, sequence, key-state
|
|
128
|
-
- **`@tanstack/react-hotkeys`** – React: `useHotkey`, `useHotkeySequence`, `useHeldKeys`, `useKeyHold`, `useHotkeyRecorder`
|
|
129
|
-
- **`@tanstack/hotkeys-devtools`** – Base devtools (in development)
|
|
130
|
-
- **`@tanstack/react-hotkeys-devtools`** – React devtools (in development)
|
|
131
|
-
|
|
132
62
|
## Get Involved
|
|
133
63
|
|
|
134
64
|
- We welcome issues and pull requests!
|
|
@@ -138,13 +68,15 @@ function Editor() {
|
|
|
138
68
|
|
|
139
69
|
## Partners
|
|
140
70
|
|
|
71
|
+
<div align="center">
|
|
72
|
+
|
|
141
73
|
<table align="center">
|
|
142
74
|
<tr>
|
|
143
75
|
<td>
|
|
144
76
|
<a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" >
|
|
145
77
|
<picture>
|
|
146
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-
|
|
147
|
-
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-
|
|
78
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-D643Zkrv.svg" height="40" />
|
|
79
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-CIzGLYU_.svg" height="40" />
|
|
148
80
|
<img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" />
|
|
149
81
|
</picture>
|
|
150
82
|
</a>
|
|
@@ -152,8 +84,8 @@ function Editor() {
|
|
|
152
84
|
<td>
|
|
153
85
|
<a href="https://www.cloudflare.com?utm_source=tanstack">
|
|
154
86
|
<picture>
|
|
155
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-
|
|
156
|
-
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-
|
|
87
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-Co-Tyjbl.svg" height="60" />
|
|
88
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-6Ojsn8yh.svg" height="60" />
|
|
157
89
|
<img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" />
|
|
158
90
|
</picture>
|
|
159
91
|
</a>
|
|
@@ -162,7 +94,7 @@ function Editor() {
|
|
|
162
94
|
</table>
|
|
163
95
|
|
|
164
96
|
<div align="center">
|
|
165
|
-
<img src="
|
|
97
|
+
<img src="media/partner_logo.svg" alt="Keys & you?" height="65">
|
|
166
98
|
<p>
|
|
167
99
|
We're looking for TanStack Hotkeys Partners to join our mission! Partner with us to push the boundaries of TanStack Hotkeys and build amazing things together.
|
|
168
100
|
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/hotkeys-devtools",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Devtools for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"src"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@tanstack/hotkeys": "0.0
|
|
40
|
+
"@tanstack/hotkeys": "0.1.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@tanstack/devtools-ui": "^0.4.4",
|