react-hotkeys-hook 5.1.0 → 5.2.1
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
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hotkeys-hook",
|
|
3
3
|
"description": "React hook for handling keyboard shortcuts",
|
|
4
|
-
"version": "5.1
|
|
4
|
+
"version": "5.2.1",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "https://github.com/JohannesKlauss/react-keymap-hook.git"
|
|
@@ -30,9 +31,10 @@
|
|
|
30
31
|
"scripts": {
|
|
31
32
|
"build": "npm run -w packages/react-hotkeys-hook build",
|
|
32
33
|
"build:documentation": "npm run -w packages/documentation build",
|
|
33
|
-
"lint": "npm run -w packages/react-hotkeys-hook lint",
|
|
34
34
|
"test": "npm run -w packages/react-hotkeys-hook test",
|
|
35
|
-
"prepublishOnly": "npm run test && npm run lint && npm run build"
|
|
35
|
+
"prepublishOnly": "npm run test && npm run lint && npm run build",
|
|
36
|
+
"format": "npx @biomejs/biome format --write packages",
|
|
37
|
+
"lint": "npx @biomejs/biome lint --write packages"
|
|
36
38
|
},
|
|
37
39
|
"workspaces": [
|
|
38
40
|
"packages/*"
|
|
@@ -40,5 +42,8 @@
|
|
|
40
42
|
"peerDependencies": {
|
|
41
43
|
"react": ">=16.8.0",
|
|
42
44
|
"react-dom": ">=16.8.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@biomejs/biome": "2.0.6"
|
|
43
48
|
}
|
|
44
49
|
}
|
|
@@ -3,4 +3,4 @@ import { Options, Keys, HotkeyCallback } from './types';
|
|
|
3
3
|
import { HotkeysProvider, useHotkeysContext } from './HotkeysProvider';
|
|
4
4
|
import { isHotkeyPressed } from './isHotkeyPressed';
|
|
5
5
|
import { default as useRecordHotkeys } from './useRecordHotkeys';
|
|
6
|
-
export { useHotkeys, useRecordHotkeys, useHotkeysContext, isHotkeyPressed, HotkeysProvider, Options, Keys, HotkeyCallback, };
|
|
6
|
+
export { useHotkeys, useRecordHotkeys, useHotkeysContext, isHotkeyPressed, HotkeysProvider, type Options, type Keys, type HotkeyCallback, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
import { jsx as
|
|
3
|
-
const
|
|
1
|
+
import { createContext as T, useContext as M, useState as A, useCallback as w, useRef as S, useLayoutEffect as z, useEffect as J } from "react";
|
|
2
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
3
|
+
const j = ["shift", "alt", "meta", "mod", "ctrl", "control"], Q = {
|
|
4
4
|
esc: "escape",
|
|
5
5
|
return: "enter",
|
|
6
6
|
left: "arrowleft",
|
|
@@ -18,106 +18,121 @@ const G = ["shift", "alt", "meta", "mod", "ctrl", "control"], O = {
|
|
|
18
18
|
ControlLeft: "ctrl",
|
|
19
19
|
ControlRight: "ctrl"
|
|
20
20
|
};
|
|
21
|
-
function
|
|
22
|
-
return (
|
|
23
|
-
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
function
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
alt:
|
|
35
|
-
ctrl:
|
|
36
|
-
shift:
|
|
37
|
-
meta:
|
|
38
|
-
mod:
|
|
39
|
-
useKey:
|
|
40
|
-
},
|
|
21
|
+
function K(e) {
|
|
22
|
+
return (Q[e.trim()] || e.trim()).toLowerCase().replace(/key|digit|numpad/, "");
|
|
23
|
+
}
|
|
24
|
+
function D(e) {
|
|
25
|
+
return j.includes(e);
|
|
26
|
+
}
|
|
27
|
+
function H(e, r = ",") {
|
|
28
|
+
return e.toLowerCase().split(r);
|
|
29
|
+
}
|
|
30
|
+
function P(e, r = "+", o = ">", i = !1, u) {
|
|
31
|
+
let n = [], c = !1;
|
|
32
|
+
e = e.trim(), e.includes(o) ? (c = !0, n = e.toLocaleLowerCase().split(o).map((f) => K(f))) : n = e.toLocaleLowerCase().split(r).map((f) => K(f));
|
|
33
|
+
const y = {
|
|
34
|
+
alt: n.includes("alt"),
|
|
35
|
+
ctrl: n.includes("ctrl") || n.includes("control"),
|
|
36
|
+
shift: n.includes("shift"),
|
|
37
|
+
meta: n.includes("meta"),
|
|
38
|
+
mod: n.includes("mod"),
|
|
39
|
+
useKey: i
|
|
40
|
+
}, d = n.filter((f) => !j.includes(f));
|
|
41
41
|
return {
|
|
42
|
-
...
|
|
43
|
-
keys:
|
|
44
|
-
description:
|
|
45
|
-
isSequence: c
|
|
42
|
+
...y,
|
|
43
|
+
keys: d,
|
|
44
|
+
description: u,
|
|
45
|
+
isSequence: c,
|
|
46
|
+
hotkey: e
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
|
-
typeof document < "u" && (document.addEventListener("keydown", (
|
|
49
|
-
|
|
50
|
-
}), document.addEventListener("keyup", (
|
|
51
|
-
|
|
49
|
+
typeof document < "u" && (document.addEventListener("keydown", (e) => {
|
|
50
|
+
e.code !== void 0 && I([K(e.code)]);
|
|
51
|
+
}), document.addEventListener("keyup", (e) => {
|
|
52
|
+
e.code !== void 0 && _([K(e.code)]);
|
|
52
53
|
})), typeof window < "u" && (window.addEventListener("blur", () => {
|
|
53
|
-
|
|
54
|
+
L.clear();
|
|
54
55
|
}), window.addEventListener("contextmenu", () => {
|
|
55
56
|
setTimeout(() => {
|
|
56
|
-
|
|
57
|
+
L.clear();
|
|
57
58
|
}, 0);
|
|
58
59
|
}));
|
|
59
|
-
const
|
|
60
|
-
function
|
|
61
|
-
return Array.isArray(
|
|
60
|
+
const L = /* @__PURE__ */ new Set();
|
|
61
|
+
function R(e) {
|
|
62
|
+
return Array.isArray(e);
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
-
return (
|
|
64
|
+
function U(e, r = ",") {
|
|
65
|
+
return (R(e) ? e : e.split(r)).every((i) => L.has(i.trim().toLowerCase()));
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
-
const r = Array.isArray(
|
|
68
|
-
|
|
67
|
+
function I(e) {
|
|
68
|
+
const r = Array.isArray(e) ? e : [e];
|
|
69
|
+
L.has("meta") && L.forEach((o) => !D(o) && L.delete(o.toLowerCase())), r.forEach((o) => L.add(o.toLowerCase()));
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
-
const r = Array.isArray(
|
|
72
|
-
|
|
71
|
+
function _(e) {
|
|
72
|
+
const r = Array.isArray(e) ? e : [e];
|
|
73
|
+
e === "meta" ? L.clear() : r.forEach((o) => L.delete(o.toLowerCase()));
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
(typeof
|
|
75
|
+
function V(e, r, o) {
|
|
76
|
+
(typeof o == "function" && o(e, r) || o === !0) && e.preventDefault();
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
return typeof
|
|
78
|
+
function X(e, r, o) {
|
|
79
|
+
return typeof o == "function" ? o(e, r) : o === !0 || o === void 0;
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
const Y = [
|
|
82
|
+
"input",
|
|
83
|
+
"textarea",
|
|
84
|
+
"select",
|
|
85
|
+
"searchbox",
|
|
86
|
+
"slider",
|
|
87
|
+
"spinbutton",
|
|
88
|
+
"menuitem",
|
|
89
|
+
"menuitemcheckbox",
|
|
90
|
+
"menuitemradio",
|
|
91
|
+
"option",
|
|
92
|
+
"radio",
|
|
93
|
+
"textbox"
|
|
94
|
+
];
|
|
95
|
+
function Z(e) {
|
|
96
|
+
return F(e, Y);
|
|
82
97
|
}
|
|
83
|
-
function
|
|
84
|
-
const { target:
|
|
85
|
-
let
|
|
86
|
-
return
|
|
98
|
+
function F(e, r = !1) {
|
|
99
|
+
const { target: o, composed: i } = e;
|
|
100
|
+
let u, n;
|
|
101
|
+
return ee(o) && i ? (u = e.composedPath()[0] && e.composedPath()[0].tagName, n = e.composedPath()[0] && e.composedPath()[0].role) : (u = o && o.tagName, n = o && o.role), R(r) ? !!(u && r && r.some((c) => c.toLowerCase() === u.toLowerCase() || c === n)) : !!(u && r && r);
|
|
87
102
|
}
|
|
88
|
-
function
|
|
89
|
-
return !!
|
|
103
|
+
function ee(e) {
|
|
104
|
+
return !!e.tagName && !e.tagName.startsWith("-") && e.tagName.includes("-");
|
|
90
105
|
}
|
|
91
|
-
function
|
|
92
|
-
return
|
|
106
|
+
function te(e, r) {
|
|
107
|
+
return e.length === 0 && r ? (console.warn(
|
|
93
108
|
'A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'
|
|
94
|
-
), !0) : r ?
|
|
109
|
+
), !0) : r ? e.some((o) => r.includes(o)) || e.includes("*") : !0;
|
|
95
110
|
}
|
|
96
|
-
const
|
|
97
|
-
const { alt:
|
|
98
|
-
if (
|
|
111
|
+
const re = (e, r, o = !1) => {
|
|
112
|
+
const { alt: i, meta: u, mod: n, shift: c, ctrl: y, keys: d, useKey: f } = r, { code: p, key: t, ctrlKey: a, metaKey: l, shiftKey: g, altKey: k } = e, m = K(p);
|
|
113
|
+
if (f && d?.length === 1 && d.includes(t))
|
|
99
114
|
return !0;
|
|
100
|
-
if (!
|
|
115
|
+
if (!d?.includes(m) && !["ctrl", "control", "unknown", "meta", "alt", "shift", "os"].includes(m))
|
|
101
116
|
return !1;
|
|
102
|
-
if (!
|
|
103
|
-
if (
|
|
117
|
+
if (!o) {
|
|
118
|
+
if (i !== k && m !== "alt" || c !== g && m !== "shift")
|
|
104
119
|
return !1;
|
|
105
|
-
if (
|
|
106
|
-
if (!
|
|
120
|
+
if (n) {
|
|
121
|
+
if (!l && !a)
|
|
107
122
|
return !1;
|
|
108
|
-
} else if (
|
|
123
|
+
} else if (u !== l && m !== "meta" && m !== "os" || y !== a && m !== "ctrl" && m !== "control")
|
|
109
124
|
return !1;
|
|
110
125
|
}
|
|
111
|
-
return
|
|
112
|
-
},
|
|
113
|
-
function
|
|
114
|
-
return /* @__PURE__ */
|
|
126
|
+
return d && d.length === 1 && d.includes(m) ? !0 : d ? U(d) : !d;
|
|
127
|
+
}, $ = T(void 0), oe = () => M($);
|
|
128
|
+
function ne({ addHotkey: e, removeHotkey: r, children: o }) {
|
|
129
|
+
return /* @__PURE__ */ b($.Provider, { value: { addHotkey: e, removeHotkey: r }, children: o });
|
|
115
130
|
}
|
|
116
|
-
function
|
|
117
|
-
return
|
|
118
|
-
Object.keys(
|
|
131
|
+
function x(e, r) {
|
|
132
|
+
return e && r && typeof e == "object" && typeof r == "object" ? Object.keys(e).length === Object.keys(r).length && // @ts-expect-error TS7053
|
|
133
|
+
Object.keys(e).reduce((o, i) => o && x(e[i], r[i]), !0) : e === r;
|
|
119
134
|
}
|
|
120
|
-
const
|
|
135
|
+
const W = T({
|
|
121
136
|
hotkeys: [],
|
|
122
137
|
activeScopes: [],
|
|
123
138
|
// This array has to be empty instead of containing '*' as default, to check if the provider is set or not
|
|
@@ -127,120 +142,141 @@ const Y = W({
|
|
|
127
142
|
},
|
|
128
143
|
disableScope: () => {
|
|
129
144
|
}
|
|
130
|
-
}),
|
|
131
|
-
const [
|
|
132
|
-
|
|
133
|
-
}, []),
|
|
134
|
-
|
|
135
|
-
}, []),
|
|
136
|
-
|
|
137
|
-
}, []),
|
|
138
|
-
|
|
139
|
-
}, []),
|
|
140
|
-
|
|
145
|
+
}), se = () => M(W), de = ({ initiallyActiveScopes: e = ["*"], children: r }) => {
|
|
146
|
+
const [o, i] = A(e), [u, n] = A([]), c = w((t) => {
|
|
147
|
+
i((a) => a.includes("*") ? [t] : Array.from(/* @__PURE__ */ new Set([...a, t])));
|
|
148
|
+
}, []), y = w((t) => {
|
|
149
|
+
i((a) => a.filter((l) => l !== t));
|
|
150
|
+
}, []), d = w((t) => {
|
|
151
|
+
i((a) => a.includes(t) ? a.filter((l) => l !== t) : a.includes("*") ? [t] : Array.from(/* @__PURE__ */ new Set([...a, t])));
|
|
152
|
+
}, []), f = w((t) => {
|
|
153
|
+
n((a) => [...a, t]);
|
|
154
|
+
}, []), p = w((t) => {
|
|
155
|
+
n((a) => a.filter((l) => !x(l, t)));
|
|
141
156
|
}, []);
|
|
142
|
-
return /* @__PURE__ */
|
|
143
|
-
|
|
157
|
+
return /* @__PURE__ */ b(
|
|
158
|
+
W.Provider,
|
|
144
159
|
{
|
|
145
|
-
value: { activeScopes:
|
|
146
|
-
children: /* @__PURE__ */
|
|
160
|
+
value: { activeScopes: o, hotkeys: u, enableScope: c, disableScope: y, toggleScope: d },
|
|
161
|
+
children: /* @__PURE__ */ b(ne, { addHotkey: f, removeHotkey: p, children: r })
|
|
147
162
|
}
|
|
148
163
|
);
|
|
149
164
|
};
|
|
150
|
-
function
|
|
151
|
-
const r =
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
},
|
|
157
|
-
function
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
return
|
|
162
|
-
if (
|
|
165
|
+
function ie(e) {
|
|
166
|
+
const r = S(void 0);
|
|
167
|
+
return x(r.current, e) || (r.current = e), r.current;
|
|
168
|
+
}
|
|
169
|
+
const N = (e) => {
|
|
170
|
+
e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
|
|
171
|
+
}, ue = typeof window < "u" ? z : J;
|
|
172
|
+
function fe(e, r, o, i) {
|
|
173
|
+
const u = S(null), n = S(!1), c = Array.isArray(o) ? Array.isArray(i) ? void 0 : i : o, y = R(e) ? e.join(c?.delimiter) : e, d = Array.isArray(o) ? o : Array.isArray(i) ? i : void 0, f = w(r, d ?? []), p = S(f);
|
|
174
|
+
d ? p.current = f : p.current = r;
|
|
175
|
+
const t = ie(c), { activeScopes: a } = se(), l = oe();
|
|
176
|
+
return ue(() => {
|
|
177
|
+
if (t?.enabled === !1 || !te(a, t?.scopes))
|
|
163
178
|
return;
|
|
164
|
-
let
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
F(o);
|
|
179
|
+
let g = [], k;
|
|
180
|
+
const m = (s, B = !1) => {
|
|
181
|
+
if (!(Z(s) && !F(s, t?.enableOnFormTags))) {
|
|
182
|
+
if (u.current !== null) {
|
|
183
|
+
const v = u.current.getRootNode();
|
|
184
|
+
if ((v instanceof Document || v instanceof ShadowRoot) && v.activeElement !== u.current && !u.current.contains(v.activeElement)) {
|
|
185
|
+
N(s);
|
|
172
186
|
return;
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
189
|
+
s.target?.isContentEditable && !t?.enableOnContentEditable || H(y, t?.delimiter).forEach((v) => {
|
|
190
|
+
if (v.includes(t?.splitKey ?? "+") && v.includes(t?.sequenceSplitKey ?? ">")) {
|
|
191
|
+
console.warn(
|
|
192
|
+
`Hotkey ${v} contains both ${t?.splitKey ?? "+"} and ${t?.sequenceSplitKey ?? ">"} which is not supported.`
|
|
193
|
+
);
|
|
179
194
|
return;
|
|
180
195
|
}
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
const h = P(
|
|
197
|
+
v,
|
|
198
|
+
t?.splitKey,
|
|
199
|
+
t?.sequenceSplitKey,
|
|
200
|
+
t?.useKey,
|
|
201
|
+
t?.description
|
|
202
|
+
);
|
|
203
|
+
if (h.isSequence) {
|
|
204
|
+
k = setTimeout(() => {
|
|
205
|
+
g = [];
|
|
206
|
+
}, t?.sequenceTimeoutMs ?? 1e3);
|
|
207
|
+
const C = h.useKey ? s.key : K(s.code);
|
|
208
|
+
if (D(C.toLowerCase()))
|
|
188
209
|
return;
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
-
|
|
210
|
+
g.push(C);
|
|
211
|
+
const G = h.keys?.[g.length - 1];
|
|
212
|
+
if (C !== G) {
|
|
213
|
+
g = [], k && clearTimeout(k);
|
|
193
214
|
return;
|
|
194
215
|
}
|
|
195
|
-
|
|
196
|
-
} else if (
|
|
197
|
-
if (
|
|
216
|
+
g.length === h.keys?.length && (p.current(s, h), k && clearTimeout(k), g = []);
|
|
217
|
+
} else if (re(s, h, t?.ignoreModifiers) || h.keys?.includes("*")) {
|
|
218
|
+
if (t?.ignoreEventWhen?.(s) || B && n.current)
|
|
198
219
|
return;
|
|
199
|
-
if (
|
|
200
|
-
|
|
220
|
+
if (V(s, h, t?.preventDefault), !X(s, h, t?.enabled)) {
|
|
221
|
+
N(s);
|
|
201
222
|
return;
|
|
202
223
|
}
|
|
203
|
-
|
|
224
|
+
p.current(s, h), B || (n.current = !0);
|
|
204
225
|
}
|
|
205
226
|
});
|
|
206
227
|
}
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
return
|
|
213
|
-
(
|
|
214
|
-
|
|
228
|
+
}, O = (s) => {
|
|
229
|
+
s.code !== void 0 && (I(K(s.code)), (t?.keydown === void 0 && t?.keyup !== !0 || t?.keydown) && m(s));
|
|
230
|
+
}, q = (s) => {
|
|
231
|
+
s.code !== void 0 && (_(K(s.code)), n.current = !1, t?.keyup && m(s, !0));
|
|
232
|
+
}, E = u.current || c?.document || document;
|
|
233
|
+
return E.addEventListener("keyup", q, c?.eventListenerOptions), E.addEventListener("keydown", O, c?.eventListenerOptions), l && H(y, t?.delimiter).forEach(
|
|
234
|
+
(s) => l.addHotkey(
|
|
235
|
+
P(
|
|
236
|
+
s,
|
|
237
|
+
t?.splitKey,
|
|
238
|
+
t?.sequenceSplitKey,
|
|
239
|
+
t?.useKey,
|
|
240
|
+
t?.description
|
|
241
|
+
)
|
|
215
242
|
)
|
|
216
243
|
), () => {
|
|
217
|
-
|
|
218
|
-
(
|
|
219
|
-
|
|
244
|
+
E.removeEventListener("keyup", q, c?.eventListenerOptions), E.removeEventListener("keydown", O, c?.eventListenerOptions), l && H(y, t?.delimiter).forEach(
|
|
245
|
+
(s) => l.removeHotkey(
|
|
246
|
+
P(
|
|
247
|
+
s,
|
|
248
|
+
t?.splitKey,
|
|
249
|
+
t?.sequenceSplitKey,
|
|
250
|
+
t?.useKey,
|
|
251
|
+
t?.description
|
|
252
|
+
)
|
|
220
253
|
)
|
|
221
|
-
),
|
|
254
|
+
), g = [], k && clearTimeout(k);
|
|
222
255
|
};
|
|
223
|
-
}, [
|
|
224
|
-
}
|
|
225
|
-
function
|
|
226
|
-
const [r,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
256
|
+
}, [y, t, a]), u;
|
|
257
|
+
}
|
|
258
|
+
function le(e = !1) {
|
|
259
|
+
const [r, o] = A(/* @__PURE__ */ new Set()), [i, u] = A(!1), n = w(
|
|
260
|
+
(f) => {
|
|
261
|
+
f.code !== void 0 && (f.preventDefault(), f.stopPropagation(), o((p) => {
|
|
262
|
+
const t = new Set(p);
|
|
263
|
+
return t.add(K(e ? f.key : f.code)), t;
|
|
264
|
+
}));
|
|
265
|
+
},
|
|
266
|
+
[e]
|
|
267
|
+
), c = w(() => {
|
|
268
|
+
typeof document < "u" && (document.removeEventListener("keydown", n), u(!1));
|
|
269
|
+
}, [n]), y = w(() => {
|
|
270
|
+
o(/* @__PURE__ */ new Set()), typeof document < "u" && (c(), document.addEventListener("keydown", n), u(!0));
|
|
271
|
+
}, [n, c]), d = w(() => {
|
|
272
|
+
o(/* @__PURE__ */ new Set());
|
|
237
273
|
}, []);
|
|
238
|
-
return [r, { start:
|
|
274
|
+
return [r, { start: y, stop: c, resetKeys: d, isRecording: i }];
|
|
239
275
|
}
|
|
240
276
|
export {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
277
|
+
de as HotkeysProvider,
|
|
278
|
+
U as isHotkeyPressed,
|
|
279
|
+
fe as useHotkeys,
|
|
280
|
+
se as useHotkeysContext,
|
|
281
|
+
le as useRecordHotkeys
|
|
246
282
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
export type FormTags = 'input' | 'textarea' | 'select' | 'INPUT' | 'TEXTAREA' | 'SELECT';
|
|
2
|
+
export type FormTags = 'input' | 'textarea' | 'select' | 'INPUT' | 'TEXTAREA' | 'SELECT' | 'searchbox' | 'slider' | 'spinbutton' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'radio' | 'textbox';
|
|
3
3
|
export type Keys = string | readonly string[];
|
|
4
4
|
export type Scopes = string | readonly string[];
|
|
5
5
|
export type EventListenerOptions = {
|
|
@@ -21,6 +21,7 @@ export type Hotkey = KeyboardModifiers & {
|
|
|
21
21
|
scopes?: Scopes;
|
|
22
22
|
description?: string;
|
|
23
23
|
isSequence?: boolean;
|
|
24
|
+
hotkey: string;
|
|
24
25
|
};
|
|
25
26
|
export type HotkeysEvent = Hotkey;
|
|
26
27
|
export type HotkeyCallback = (keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent) => void;
|