@tanstack/react-hotkeys 0.0.1 → 0.0.3

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -45
  3. package/dist/HotkeysProvider.cjs +23 -0
  4. package/dist/HotkeysProvider.cjs.map +1 -0
  5. package/dist/HotkeysProvider.d.cts +27 -0
  6. package/dist/HotkeysProvider.d.ts +27 -0
  7. package/dist/HotkeysProvider.js +19 -0
  8. package/dist/HotkeysProvider.js.map +1 -0
  9. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  10. package/dist/index.cjs +25 -0
  11. package/dist/index.d.cts +9 -0
  12. package/dist/index.d.ts +9 -0
  13. package/dist/index.js +11 -0
  14. package/dist/useHeldKeyCodes.cjs +38 -0
  15. package/dist/useHeldKeyCodes.cjs.map +1 -0
  16. package/dist/useHeldKeyCodes.d.cts +31 -0
  17. package/dist/useHeldKeyCodes.d.ts +31 -0
  18. package/dist/useHeldKeyCodes.js +37 -0
  19. package/dist/useHeldKeyCodes.js.map +1 -0
  20. package/dist/useHeldKeys.cjs +34 -0
  21. package/dist/useHeldKeys.cjs.map +1 -0
  22. package/dist/useHeldKeys.d.cts +27 -0
  23. package/dist/useHeldKeys.d.ts +27 -0
  24. package/dist/useHeldKeys.js +33 -0
  25. package/dist/useHeldKeys.js.map +1 -0
  26. package/dist/useHotkey.cjs +119 -0
  27. package/dist/useHotkey.cjs.map +1 -0
  28. package/dist/useHotkey.d.cts +73 -0
  29. package/dist/useHotkey.d.ts +73 -0
  30. package/dist/useHotkey.js +118 -0
  31. package/dist/useHotkey.js.map +1 -0
  32. package/dist/useHotkeyRecorder.cjs +72 -0
  33. package/dist/useHotkeyRecorder.cjs.map +1 -0
  34. package/dist/useHotkeyRecorder.d.cts +57 -0
  35. package/dist/useHotkeyRecorder.d.ts +57 -0
  36. package/dist/useHotkeyRecorder.js +71 -0
  37. package/dist/useHotkeyRecorder.js.map +1 -0
  38. package/dist/useHotkeySequence.cjs +65 -0
  39. package/dist/useHotkeySequence.cjs.map +1 -0
  40. package/dist/useHotkeySequence.d.cts +43 -0
  41. package/dist/useHotkeySequence.d.ts +43 -0
  42. package/dist/useHotkeySequence.js +64 -0
  43. package/dist/useHotkeySequence.js.map +1 -0
  44. package/dist/useKeyHold.cjs +54 -0
  45. package/dist/useKeyHold.cjs.map +1 -0
  46. package/dist/useKeyHold.d.cts +47 -0
  47. package/dist/useKeyHold.d.ts +47 -0
  48. package/dist/useKeyHold.js +53 -0
  49. package/dist/useKeyHold.js.map +1 -0
  50. package/package.json +66 -7
  51. package/src/HotkeysProvider.tsx +51 -0
  52. package/src/index.ts +13 -0
  53. package/src/useHeldKeyCodes.ts +33 -0
  54. package/src/useHeldKeys.ts +29 -0
  55. package/src/useHotkey.ts +191 -0
  56. package/src/useHotkeyRecorder.ts +101 -0
  57. package/src/useHotkeySequence.ts +92 -0
  58. package/src/useKeyHold.ts +52 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,121 @@
1
- # @tanstack/react-hotkeys
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@tanstack/react-hotkeys`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
1
+ <div align="center">
2
+ <img src="./media/header_hotkeys.png" alt="TanStack Hotkeys" />
3
+ </div>
4
+
5
+ <br />
6
+
7
+ <div align="center">
8
+ <a href="https://www.npmjs.com/package/@tanstack/hotkeys" target="\_parent">
9
+ <img alt="" src="https://img.shields.io/npm/dm/@tanstack/hotkeys.svg" alt="npm downloads" />
10
+ </a>
11
+ <a href="https://github.com/TanStack/hotkeys" target="\_parent">
12
+ <img alt="" src="https://img.shields.io/github/stars/TanStack/hotkeys.svg?style=social&label=Star" alt="GitHub stars" />
13
+ </a>
14
+ <a href="https://bundlephobia.com/result?p=@tanstack/react-hotkeys@latest" target="\_parent">
15
+ <img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/react-hotkeys@latest" alt="Bundle size" />
16
+ </a>
17
+ </div>
18
+
19
+ <div align="center">
20
+ <a href="#badge">
21
+ <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
22
+ </a>
23
+ <a href="#badge">
24
+ <img src="https://img.shields.io/github/v/release/tanstack/hotkeys" alt="Release"/>
25
+ </a>
26
+ <a href="https://twitter.com/tan_stack">
27
+ <img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/>
28
+ </a>
29
+ </div>
30
+
31
+ <div align="center">
32
+
33
+ ### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
34
+
35
+ </div>
36
+
37
+ # TanStack Hotkeys
38
+
39
+ > [!NOTE]
40
+ > TanStack Hotkeys is pre-alpha (prototyping phase). We are actively developing the library and are open to feedback and contributions.
41
+
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)
48
+
49
+ ### <a href="https://tanstack.com/hotkeys">Read the docs →</a>
50
+
51
+ <br />
52
+
53
+ > [!NOTE]
54
+ > You may know **TanStack Hotkeys** by our adapter names, too!
55
+ >
56
+ > - [**React Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/react/react-hotkeys)
57
+ > - Solid Hotkeys – needs a contributor!
58
+ > - Angular Hotkeys – needs a contributor!
59
+ > - Svelte Hotkeys – needs a contributor!
60
+ > - Vue Hotkeys – needs a contributor!
61
+
62
+ ## Get Involved
63
+
64
+ - We welcome issues and pull requests!
65
+ - Participate in [GitHub discussions](https://github.com/TanStack/hotkeys/discussions)
66
+ - Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ)
67
+ - See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions
68
+
69
+ ## Partners
70
+
71
+ <div align="center">
72
+
73
+ <table align="center">
74
+ <tr>
75
+ <td>
76
+ <a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" >
77
+ <picture>
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" />
80
+ <img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" />
81
+ </picture>
82
+ </a>
83
+ </td>
84
+ <td>
85
+ <a href="https://www.cloudflare.com?utm_source=tanstack">
86
+ <picture>
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" />
89
+ <img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" />
90
+ </picture>
91
+ </a>
92
+ </td>
93
+ </tr>
94
+ </table>
95
+
96
+ <div align="center">
97
+ <img src="media/partner_logo.svg" alt="Keys & you?" height="65">
98
+ <p>
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.
100
+ </p>
101
+ <a href="mailto:partners@tanstack.com?subject=TanStack Hotkeys Partnership"><b>LET'S CHAT</b></a>
102
+ </div>
103
+
104
+ </div>
105
+
106
+ ## Explore the TanStack Ecosystem
107
+
108
+ - <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages
109
+ - <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store
110
+ - <a href="https://github.com/tanstack/devtools"><b>TanStack DevTools</b></a> – Unified devtools panel
111
+ - <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state
112
+ - <a href="https://github.com/tanstack/hotkeys"><b>TanStack Hotkeys</b></a> – Type‑safe keyboard shortcuts
113
+ - <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching
114
+ - <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives
115
+ - <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state
116
+ - <a href="https://github.com/tanstack/start"><b>TanStack Start</b></a> – Full‑stack SSR & streaming
117
+ - <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store
118
+ - <a href="https://github.com/tanstack/table"><b>TanStack Table</b></a> – Headless datagrids
119
+ - <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering
120
+
121
+ … and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>
@@ -0,0 +1,23 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let react = require("react");
3
+ react = require_runtime.__toESM(react);
4
+
5
+ //#region src/HotkeysProvider.tsx
6
+ const HotkeysContext = (0, react.createContext)(null);
7
+ const DEFAULT_OPTIONS = {};
8
+ function HotkeysProvider({ children, defaultOptions = DEFAULT_OPTIONS }) {
9
+ const contextValue = (0, react.useMemo)(() => ({ defaultOptions }), [defaultOptions]);
10
+ return /* @__PURE__ */ react.default.createElement(HotkeysContext.Provider, { value: contextValue }, children);
11
+ }
12
+ function useHotkeysContext() {
13
+ return (0, react.useContext)(HotkeysContext);
14
+ }
15
+ function useDefaultHotkeysOptions() {
16
+ return (0, react.useContext)(HotkeysContext)?.defaultOptions ?? {};
17
+ }
18
+
19
+ //#endregion
20
+ exports.HotkeysProvider = HotkeysProvider;
21
+ exports.useDefaultHotkeysOptions = useDefaultHotkeysOptions;
22
+ exports.useHotkeysContext = useHotkeysContext;
23
+ //# sourceMappingURL=HotkeysProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeysProvider.cjs","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport type { HotkeyRecorderOptions } from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: ReactNode\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function HotkeysProvider({\n children,\n defaultOptions = DEFAULT_OPTIONS,\n}: HotkeysProviderProps) {\n const contextValue: HotkeysContextValue = useMemo(\n () => ({\n defaultOptions,\n }),\n [defaultOptions],\n )\n\n return (\n <HotkeysContext.Provider value={contextValue}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;;AAgBA,MAAM,0CAA2D,KAAK;AAOtE,MAAM,kBAA0C,EAAE;AAElD,SAAgB,gBAAgB,EAC9B,UACA,iBAAiB,mBACM;CACvB,MAAM,yCACG,EACL,gBACD,GACD,CAAC,eAAe,CACjB;AAED,QACE,4CAAC,eAAe,YAAS,OAAO,gBAC7B,SACuB;;AAI9B,SAAgB,oBAAoB;AAClC,8BAAkB,eAAe;;AAGnC,SAAgB,2BAA2B;AAEzC,8BAD2B,eAAe,EAC1B,kBAAkB,EAAE"}
@@ -0,0 +1,27 @@
1
+ import { UseHotkeyOptions } from "./useHotkey.cjs";
2
+ import { UseHotkeySequenceOptions } from "./useHotkeySequence.cjs";
3
+ import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
4
+ import React, { ReactNode } from "react";
5
+
6
+ //#region src/HotkeysProvider.d.ts
7
+ interface HotkeysProviderOptions {
8
+ hotkey?: Partial<UseHotkeyOptions>;
9
+ hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
10
+ hotkeySequence?: Partial<UseHotkeySequenceOptions>;
11
+ }
12
+ interface HotkeysContextValue {
13
+ defaultOptions: HotkeysProviderOptions;
14
+ }
15
+ interface HotkeysProviderProps {
16
+ children: ReactNode;
17
+ defaultOptions?: HotkeysProviderOptions;
18
+ }
19
+ declare function HotkeysProvider({
20
+ children,
21
+ defaultOptions
22
+ }: HotkeysProviderProps): React.JSX.Element;
23
+ declare function useHotkeysContext(): HotkeysContextValue | null;
24
+ declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
25
+ //#endregion
26
+ export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
27
+ //# sourceMappingURL=HotkeysProvider.d.cts.map
@@ -0,0 +1,27 @@
1
+ import { UseHotkeyOptions } from "./useHotkey.js";
2
+ import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
3
+ import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
4
+ import React, { ReactNode } from "react";
5
+
6
+ //#region src/HotkeysProvider.d.ts
7
+ interface HotkeysProviderOptions {
8
+ hotkey?: Partial<UseHotkeyOptions>;
9
+ hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
10
+ hotkeySequence?: Partial<UseHotkeySequenceOptions>;
11
+ }
12
+ interface HotkeysContextValue {
13
+ defaultOptions: HotkeysProviderOptions;
14
+ }
15
+ interface HotkeysProviderProps {
16
+ children: ReactNode;
17
+ defaultOptions?: HotkeysProviderOptions;
18
+ }
19
+ declare function HotkeysProvider({
20
+ children,
21
+ defaultOptions
22
+ }: HotkeysProviderProps): React.JSX.Element;
23
+ declare function useHotkeysContext(): HotkeysContextValue | null;
24
+ declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
25
+ //#endregion
26
+ export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
27
+ //# sourceMappingURL=HotkeysProvider.d.ts.map
@@ -0,0 +1,19 @@
1
+ import React, { createContext, useContext, useMemo } from "react";
2
+
3
+ //#region src/HotkeysProvider.tsx
4
+ const HotkeysContext = createContext(null);
5
+ const DEFAULT_OPTIONS = {};
6
+ function HotkeysProvider({ children, defaultOptions = DEFAULT_OPTIONS }) {
7
+ const contextValue = useMemo(() => ({ defaultOptions }), [defaultOptions]);
8
+ return /* @__PURE__ */ React.createElement(HotkeysContext.Provider, { value: contextValue }, children);
9
+ }
10
+ function useHotkeysContext() {
11
+ return useContext(HotkeysContext);
12
+ }
13
+ function useDefaultHotkeysOptions() {
14
+ return useContext(HotkeysContext)?.defaultOptions ?? {};
15
+ }
16
+
17
+ //#endregion
18
+ export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
19
+ //# sourceMappingURL=HotkeysProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeysProvider.js","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport type { HotkeyRecorderOptions } from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: ReactNode\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function HotkeysProvider({\n children,\n defaultOptions = DEFAULT_OPTIONS,\n}: HotkeysProviderProps) {\n const contextValue: HotkeysContextValue = useMemo(\n () => ({\n defaultOptions,\n }),\n [defaultOptions],\n )\n\n return (\n <HotkeysContext.Provider value={contextValue}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;AAgBA,MAAM,iBAAiB,cAA0C,KAAK;AAOtE,MAAM,kBAA0C,EAAE;AAElD,SAAgB,gBAAgB,EAC9B,UACA,iBAAiB,mBACM;CACvB,MAAM,eAAoC,eACjC,EACL,gBACD,GACD,CAAC,eAAe,CACjB;AAED,QACE,oCAAC,eAAe,YAAS,OAAO,gBAC7B,SACuB;;AAI9B,SAAgB,oBAAoB;AAClC,QAAO,WAAW,eAAe;;AAGnC,SAAgB,2BAA2B;AAEzC,QADgB,WAAW,eAAe,EAC1B,kBAAkB,EAAE"}
@@ -0,0 +1,29 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/index.cjs ADDED
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_HotkeysProvider = require('./HotkeysProvider.cjs');
3
+ const require_useHotkey = require('./useHotkey.cjs');
4
+ const require_useHeldKeys = require('./useHeldKeys.cjs');
5
+ const require_useHeldKeyCodes = require('./useHeldKeyCodes.cjs');
6
+ const require_useKeyHold = require('./useKeyHold.cjs');
7
+ const require_useHotkeySequence = require('./useHotkeySequence.cjs');
8
+ const require_useHotkeyRecorder = require('./useHotkeyRecorder.cjs');
9
+
10
+ exports.HotkeysProvider = require_HotkeysProvider.HotkeysProvider;
11
+ exports.useDefaultHotkeysOptions = require_HotkeysProvider.useDefaultHotkeysOptions;
12
+ exports.useHeldKeyCodes = require_useHeldKeyCodes.useHeldKeyCodes;
13
+ exports.useHeldKeys = require_useHeldKeys.useHeldKeys;
14
+ exports.useHotkey = require_useHotkey.useHotkey;
15
+ exports.useHotkeyRecorder = require_useHotkeyRecorder.useHotkeyRecorder;
16
+ exports.useHotkeySequence = require_useHotkeySequence.useHotkeySequence;
17
+ exports.useHotkeysContext = require_HotkeysProvider.useHotkeysContext;
18
+ exports.useKeyHold = require_useKeyHold.useKeyHold;
19
+ var _tanstack_hotkeys = require("@tanstack/hotkeys");
20
+ Object.keys(_tanstack_hotkeys).forEach(function (k) {
21
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
22
+ enumerable: true,
23
+ get: function () { return _tanstack_hotkeys[k]; }
24
+ });
25
+ });
@@ -0,0 +1,9 @@
1
+ import { UseHotkeyOptions, useHotkey } from "./useHotkey.cjs";
2
+ import { UseHotkeySequenceOptions, useHotkeySequence } from "./useHotkeySequence.cjs";
3
+ import { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.cjs";
4
+ import { useHeldKeys } from "./useHeldKeys.cjs";
5
+ import { useHeldKeyCodes } from "./useHeldKeyCodes.cjs";
6
+ import { useKeyHold } from "./useKeyHold.cjs";
7
+ import { ReactHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.cjs";
8
+ export * from "@tanstack/hotkeys";
9
+ export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, ReactHotkeyRecorder, UseHotkeyOptions, UseHotkeySequenceOptions, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeySequence, useHotkeysContext, useKeyHold };
@@ -0,0 +1,9 @@
1
+ import { UseHotkeyOptions, useHotkey } from "./useHotkey.js";
2
+ import { UseHotkeySequenceOptions, useHotkeySequence } from "./useHotkeySequence.js";
3
+ import { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
4
+ import { useHeldKeys } from "./useHeldKeys.js";
5
+ import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
6
+ import { useKeyHold } from "./useKeyHold.js";
7
+ import { ReactHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.js";
8
+ export * from "@tanstack/hotkeys";
9
+ export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, ReactHotkeyRecorder, UseHotkeyOptions, UseHotkeySequenceOptions, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeySequence, useHotkeysContext, useKeyHold };
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
2
+ import { useHotkey } from "./useHotkey.js";
3
+ import { useHeldKeys } from "./useHeldKeys.js";
4
+ import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
5
+ import { useKeyHold } from "./useKeyHold.js";
6
+ import { useHotkeySequence } from "./useHotkeySequence.js";
7
+ import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
8
+
9
+ export * from "@tanstack/hotkeys"
10
+
11
+ export { HotkeysProvider, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeySequence, useHotkeysContext, useKeyHold };
@@ -0,0 +1,38 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let _tanstack_hotkeys = require("@tanstack/hotkeys");
3
+ let _tanstack_react_store = require("@tanstack/react-store");
4
+
5
+ //#region src/useHeldKeyCodes.ts
6
+ /**
7
+ * React hook that returns a map of currently held key names to their physical `event.code` values.
8
+ *
9
+ * This is useful for debugging which physical key was pressed (e.g. distinguishing
10
+ * left vs right Shift via "ShiftLeft" / "ShiftRight").
11
+ *
12
+ * @returns Record mapping normalized key names to their `event.code` values
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * function KeyDebugDisplay() {
17
+ * const heldKeys = useHeldKeys()
18
+ * const heldCodes = useHeldKeyCodes()
19
+ *
20
+ * return (
21
+ * <div>
22
+ * {heldKeys.map((key) => (
23
+ * <kbd key={key}>
24
+ * {key} <small>{heldCodes[key]}</small>
25
+ * </kbd>
26
+ * ))}
27
+ * </div>
28
+ * )
29
+ * }
30
+ * ```
31
+ */
32
+ function useHeldKeyCodes() {
33
+ return (0, _tanstack_react_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
34
+ }
35
+
36
+ //#endregion
37
+ exports.useHeldKeyCodes = useHeldKeyCodes;
38
+ //# sourceMappingURL=useHeldKeyCodes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldKeyCodes.cjs","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * React hook that returns a map of currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n *\n * return (\n * <div>\n * {heldKeys.map((key) => (\n * <kbd key={key}>\n * {key} <small>{heldCodes[key]}</small>\n * </kbd>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeyCodes(): Record<string, string> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,kBAA0C;AAExD,uFADoC,CACZ,QAAQ,UAAU,MAAM,UAAU"}
@@ -0,0 +1,31 @@
1
+ //#region src/useHeldKeyCodes.d.ts
2
+ /**
3
+ * React hook that returns a map of currently held key names to their physical `event.code` values.
4
+ *
5
+ * This is useful for debugging which physical key was pressed (e.g. distinguishing
6
+ * left vs right Shift via "ShiftLeft" / "ShiftRight").
7
+ *
8
+ * @returns Record mapping normalized key names to their `event.code` values
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * function KeyDebugDisplay() {
13
+ * const heldKeys = useHeldKeys()
14
+ * const heldCodes = useHeldKeyCodes()
15
+ *
16
+ * return (
17
+ * <div>
18
+ * {heldKeys.map((key) => (
19
+ * <kbd key={key}>
20
+ * {key} <small>{heldCodes[key]}</small>
21
+ * </kbd>
22
+ * ))}
23
+ * </div>
24
+ * )
25
+ * }
26
+ * ```
27
+ */
28
+ declare function useHeldKeyCodes(): Record<string, string>;
29
+ //#endregion
30
+ export { useHeldKeyCodes };
31
+ //# sourceMappingURL=useHeldKeyCodes.d.cts.map
@@ -0,0 +1,31 @@
1
+ //#region src/useHeldKeyCodes.d.ts
2
+ /**
3
+ * React hook that returns a map of currently held key names to their physical `event.code` values.
4
+ *
5
+ * This is useful for debugging which physical key was pressed (e.g. distinguishing
6
+ * left vs right Shift via "ShiftLeft" / "ShiftRight").
7
+ *
8
+ * @returns Record mapping normalized key names to their `event.code` values
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * function KeyDebugDisplay() {
13
+ * const heldKeys = useHeldKeys()
14
+ * const heldCodes = useHeldKeyCodes()
15
+ *
16
+ * return (
17
+ * <div>
18
+ * {heldKeys.map((key) => (
19
+ * <kbd key={key}>
20
+ * {key} <small>{heldCodes[key]}</small>
21
+ * </kbd>
22
+ * ))}
23
+ * </div>
24
+ * )
25
+ * }
26
+ * ```
27
+ */
28
+ declare function useHeldKeyCodes(): Record<string, string>;
29
+ //#endregion
30
+ export { useHeldKeyCodes };
31
+ //# sourceMappingURL=useHeldKeyCodes.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { getKeyStateTracker } from "@tanstack/hotkeys";
2
+ import { useStore } from "@tanstack/react-store";
3
+
4
+ //#region src/useHeldKeyCodes.ts
5
+ /**
6
+ * React hook that returns a map of currently held key names to their physical `event.code` values.
7
+ *
8
+ * This is useful for debugging which physical key was pressed (e.g. distinguishing
9
+ * left vs right Shift via "ShiftLeft" / "ShiftRight").
10
+ *
11
+ * @returns Record mapping normalized key names to their `event.code` values
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * function KeyDebugDisplay() {
16
+ * const heldKeys = useHeldKeys()
17
+ * const heldCodes = useHeldKeyCodes()
18
+ *
19
+ * return (
20
+ * <div>
21
+ * {heldKeys.map((key) => (
22
+ * <kbd key={key}>
23
+ * {key} <small>{heldCodes[key]}</small>
24
+ * </kbd>
25
+ * ))}
26
+ * </div>
27
+ * )
28
+ * }
29
+ * ```
30
+ */
31
+ function useHeldKeyCodes() {
32
+ return useStore(getKeyStateTracker().store, (state) => state.heldCodes);
33
+ }
34
+
35
+ //#endregion
36
+ export { useHeldKeyCodes };
37
+ //# sourceMappingURL=useHeldKeyCodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldKeyCodes.js","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * React hook that returns a map of currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n *\n * return (\n * <div>\n * {heldKeys.map((key) => (\n * <kbd key={key}>\n * {key} <small>{heldCodes[key]}</small>\n * </kbd>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeyCodes(): Record<string, string> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,kBAA0C;AAExD,QAAO,SADS,oBAAoB,CACZ,QAAQ,UAAU,MAAM,UAAU"}
@@ -0,0 +1,34 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let _tanstack_hotkeys = require("@tanstack/hotkeys");
3
+ let _tanstack_react_store = require("@tanstack/react-store");
4
+
5
+ //#region src/useHeldKeys.ts
6
+ /**
7
+ * React hook that returns an array of currently held keyboard keys.
8
+ *
9
+ * This hook uses `useStore` from `@tanstack/react-store` to subscribe
10
+ * to the global KeyStateTracker and updates whenever keys are pressed
11
+ * or released.
12
+ *
13
+ * @returns Array of currently held key names
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * function KeyDisplay() {
18
+ * const heldKeys = useHeldKeys()
19
+ *
20
+ * return (
21
+ * <div>
22
+ * Currently pressed: {heldKeys.join(' + ') || 'None'}
23
+ * </div>
24
+ * )
25
+ * }
26
+ * ```
27
+ */
28
+ function useHeldKeys() {
29
+ return (0, _tanstack_react_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
30
+ }
31
+
32
+ //#endregion
33
+ exports.useHeldKeys = useHeldKeys;
34
+ //# sourceMappingURL=useHeldKeys.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldKeys.cjs","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * React hook that returns an array of currently held keyboard keys.\n *\n * This hook uses `useStore` from `@tanstack/react-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Array of currently held key names\n *\n * @example\n * ```tsx\n * function KeyDisplay() {\n * const heldKeys = useHeldKeys()\n *\n * return (\n * <div>\n * Currently pressed: {heldKeys.join(' + ') || 'None'}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeys(): Array<string> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAA6B;AAE3C,uFADoC,CACZ,QAAQ,UAAU,MAAM,SAAS"}
@@ -0,0 +1,27 @@
1
+ //#region src/useHeldKeys.d.ts
2
+ /**
3
+ * React hook that returns an array of currently held keyboard keys.
4
+ *
5
+ * This hook uses `useStore` from `@tanstack/react-store` to subscribe
6
+ * to the global KeyStateTracker and updates whenever keys are pressed
7
+ * or released.
8
+ *
9
+ * @returns Array of currently held key names
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function KeyDisplay() {
14
+ * const heldKeys = useHeldKeys()
15
+ *
16
+ * return (
17
+ * <div>
18
+ * Currently pressed: {heldKeys.join(' + ') || 'None'}
19
+ * </div>
20
+ * )
21
+ * }
22
+ * ```
23
+ */
24
+ declare function useHeldKeys(): Array<string>;
25
+ //#endregion
26
+ export { useHeldKeys };
27
+ //# sourceMappingURL=useHeldKeys.d.cts.map
@@ -0,0 +1,27 @@
1
+ //#region src/useHeldKeys.d.ts
2
+ /**
3
+ * React hook that returns an array of currently held keyboard keys.
4
+ *
5
+ * This hook uses `useStore` from `@tanstack/react-store` to subscribe
6
+ * to the global KeyStateTracker and updates whenever keys are pressed
7
+ * or released.
8
+ *
9
+ * @returns Array of currently held key names
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function KeyDisplay() {
14
+ * const heldKeys = useHeldKeys()
15
+ *
16
+ * return (
17
+ * <div>
18
+ * Currently pressed: {heldKeys.join(' + ') || 'None'}
19
+ * </div>
20
+ * )
21
+ * }
22
+ * ```
23
+ */
24
+ declare function useHeldKeys(): Array<string>;
25
+ //#endregion
26
+ export { useHeldKeys };
27
+ //# sourceMappingURL=useHeldKeys.d.ts.map