feat(devtools): Handle keyboard shortcuts with TanStack Hotkeys #582
Showing 34 changed files with 32 additions and 14 deletions (loading 30).
x
@@ -0,0 +1,14 @@
+---
+'@tanstack/devtools': minor
+---
+
+Handle every devtools keyboard shortcut with TanStack Hotkeys.
+
+- `openHotkey` is a hotkey string in TanStack Hotkeys syntax, such as `'Control+~'` (the default) or `'Mod+Shift+D'`. The array form, such as `['Control', '~']`, is deprecated. It still works and converts to a string when the devtools load.
+- `inspectHotkey` takes modifier names. `CtrlOrMeta` is deprecated in favor of `Mod`, which is Command on macOS and Control on other platforms. The default is `['Shift', 'Alt', 'Mod']`.
+- Shortcuts saved in the Settings tab by an older version convert the same way, so they keep working. A saved shortcut that has no TanStack Hotkeys form, such as two keys pressed together, falls back to the config or the default. Before, `CtrlOrMeta` matched either key on every platform. `Mod` matches Command on macOS and Control elsewhere.
+- The Settings tab records the open shortcut from a key press, including in the picture-in-picture window, and rejects a shortcut that the app already registered with TanStack Hotkeys.
+- Escape no longer closes the devtools when it closes an open dialog or popover of the app. Escape while moving a pane with the keyboard cancels the move and leaves the panel open.
+- Alt+M for magnetic trigger mode now works on macOS, and it no longer fires while you type in a text field.
+- The devtools hotkeys are in the `tanstack-devtools` scope. In an app that also uses TanStack Hotkeys, an enabled devtools hotkey runs instead of the app's global hotkey for the same key, such as Escape while the panel is open. An app with an exclusive scope can keep the devtools hotkeys working with `exclusive: { allow: ['tanstack-devtools'] }`.
+- `@tanstack/hotkeys` is a new dependency, and `@solid-primitives/keyboard` is removed. An app that already uses TanStack Hotkeys shares one hotkey manager with the devtools.
@@ -47,22 +47,29 @@
-- `openHotkey` - The hotkey set to open the devtools
+- `openHotkey` - The hotkey that opens and closes the devtools, written in [TanStack Hotkeys](https://tanstack.com/hotkeys) syntax. `Mod` is Command on macOS and Control on other platforms. The hotkey does not fire while you type in a text field. The default is `'Control+~'`. The older array form, such as `['Control', '~']`, is deprecated and converts to a string.
-type ModifierKey = 'Alt' | 'Control' | 'Meta' | 'Shift' | 'CtrlOrMeta';
-type KeyboardKey = ModifierKey | (string & {});
+import type { Hotkey } from '@tanstack/hotkeys'
-{ openHotkey: Array<KeyboardKey> }