react-better-hotkeys 0.2.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 (105) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +74 -0
  3. package/dist/HotkeyRegistry.d.ts +28 -0
  4. package/dist/HotkeyRegistry.d.ts.map +1 -0
  5. package/dist/HotkeyRegistry.js +132 -0
  6. package/dist/HotkeyTextResolver.d.ts +12 -0
  7. package/dist/HotkeyTextResolver.d.ts.map +1 -0
  8. package/dist/HotkeyTextResolver.js +45 -0
  9. package/dist/context/HotkeyContext.d.ts +8 -0
  10. package/dist/context/HotkeyContext.d.ts.map +1 -0
  11. package/dist/context/HotkeyContext.js +7 -0
  12. package/dist/context/HotkeyProvider.d.ts +4 -0
  13. package/dist/context/HotkeyProvider.d.ts.map +1 -0
  14. package/dist/context/HotkeyProvider.js +31 -0
  15. package/dist/definitions/Chord.d.ts +6 -0
  16. package/dist/definitions/Chord.d.ts.map +1 -0
  17. package/dist/definitions/Chord.js +32 -0
  18. package/dist/definitions/Hotkey.d.ts +7 -0
  19. package/dist/definitions/Hotkey.d.ts.map +1 -0
  20. package/dist/definitions/Hotkey.js +13 -0
  21. package/dist/definitions/KeyMap.d.ts +5 -0
  22. package/dist/definitions/KeyMap.d.ts.map +1 -0
  23. package/dist/definitions/KeyMap.js +583 -0
  24. package/dist/definitions/ModifierKeyCodes.d.ts +2 -0
  25. package/dist/definitions/ModifierKeyCodes.d.ts.map +1 -0
  26. package/dist/definitions/ModifierKeyCodes.js +10 -0
  27. package/dist/definitions/Sequence.d.ts +4 -0
  28. package/dist/definitions/Sequence.d.ts.map +1 -0
  29. package/dist/definitions/Sequence.js +15 -0
  30. package/dist/hooks/useHotkey.d.ts +18 -0
  31. package/dist/hooks/useHotkey.d.ts.map +1 -0
  32. package/dist/hooks/useHotkey.js +66 -0
  33. package/dist/index.d.ts +7 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +12 -0
  36. package/dist/types/hotkey/HotKeyChordDef.d.ts +4 -0
  37. package/dist/types/hotkey/HotKeyChordDef.d.ts.map +1 -0
  38. package/dist/types/hotkey/HotKeyDef.d.ts +4 -0
  39. package/dist/types/hotkey/HotKeyDef.d.ts.map +1 -0
  40. package/dist/types/hotkey/HotKeyDefBase.d.ts +11 -0
  41. package/dist/types/hotkey/HotKeyDefBase.d.ts.map +1 -0
  42. package/dist/types/hotkey/HotKeyDefChordBase.d.ts +9 -0
  43. package/dist/types/hotkey/HotKeyDefChordBase.d.ts.map +1 -0
  44. package/dist/types/hotkey/HotKeyDefSequenceBase.d.ts +6 -0
  45. package/dist/types/hotkey/HotKeyDefSequenceBase.d.ts.map +1 -0
  46. package/dist/types/hotkey/HotKeySequenceDef.d.ts +4 -0
  47. package/dist/types/hotkey/HotKeySequenceDef.d.ts.map +1 -0
  48. package/dist/types/hotkey/HotkeyCallback.d.ts +2 -0
  49. package/dist/types/hotkey/HotkeyCallback.d.ts.map +1 -0
  50. package/dist/types/hotkey/HotkeyOptions.d.ts +21 -0
  51. package/dist/types/hotkey/HotkeyOptions.d.ts.map +1 -0
  52. package/dist/types/hotkey/HotkeyTextParts.d.ts +2 -0
  53. package/dist/types/hotkey/HotkeyTextParts.d.ts.map +1 -0
  54. package/dist/types/hotkey/HotkeyType.d.ts +2 -0
  55. package/dist/types/hotkey/HotkeyType.d.ts.map +1 -0
  56. package/dist/types/hotkey/UseHotkeyFn.d.ts +3 -0
  57. package/dist/types/hotkey/UseHotkeyFn.d.ts.map +1 -0
  58. package/dist/types/hotkey/chord/ChordNode.d.ts +7 -0
  59. package/dist/types/hotkey/chord/ChordNode.d.ts.map +1 -0
  60. package/dist/types/hotkey/chord/HotkeyChordBuilder.d.ts +6 -0
  61. package/dist/types/hotkey/chord/HotkeyChordBuilder.d.ts.map +1 -0
  62. package/dist/types/hotkey/chord/IncompleteChordHotkey.d.ts +6 -0
  63. package/dist/types/hotkey/chord/IncompleteChordHotkey.d.ts.map +1 -0
  64. package/dist/types/hotkey/provider/HotkeyProviderProps.d.ts +16 -0
  65. package/dist/types/hotkey/provider/HotkeyProviderProps.d.ts.map +1 -0
  66. package/dist/types/hotkey/sequence/HotkeySequenceBuilder.d.ts +4 -0
  67. package/dist/types/hotkey/sequence/HotkeySequenceBuilder.d.ts.map +1 -0
  68. package/dist/types/hotkey/sequence/SequenceNode.d.ts +7 -0
  69. package/dist/types/hotkey/sequence/SequenceNode.d.ts.map +1 -0
  70. package/dist/types/hotkey/sequence/SequenceTree.d.ts +11 -0
  71. package/dist/types/hotkey/sequence/SequenceTree.d.ts.map +1 -0
  72. package/dist/types/key/KeyDescription.d.ts +6 -0
  73. package/dist/types/key/KeyDescription.d.ts.map +1 -0
  74. package/dist/types/key/KeyValueType.d.ts +2 -0
  75. package/dist/types/key/KeyValueType.d.ts.map +1 -0
  76. package/dist/types/key/ModifierKeyCode.d.ts +3 -0
  77. package/dist/types/key/ModifierKeyCode.d.ts.map +1 -0
  78. package/dist/types/key/PrimaryKey.d.ts +4 -0
  79. package/dist/types/key/PrimaryKey.d.ts.map +1 -0
  80. package/dist/types/key/PrimaryKeyCode.d.ts +2 -0
  81. package/dist/types/key/PrimaryKeyCode.d.ts.map +1 -0
  82. package/dist/types/key/PrimaryKeyValue.d.ts +2 -0
  83. package/dist/types/key/PrimaryKeyValue.d.ts.map +1 -0
  84. package/dist/util/checkModifierPressed.d.ts +3 -0
  85. package/dist/util/checkModifierPressed.d.ts.map +1 -0
  86. package/dist/util/checkModifierPressed.js +6 -0
  87. package/dist/util/detectOS.d.ts +3 -0
  88. package/dist/util/detectOS.d.ts.map +1 -0
  89. package/dist/util/detectOS.js +11 -0
  90. package/dist/util/isCleanKeydown.d.ts +2 -0
  91. package/dist/util/isCleanKeydown.d.ts.map +1 -0
  92. package/dist/util/isCleanKeydown.js +6 -0
  93. package/dist/util/isEditable.d.ts +2 -0
  94. package/dist/util/isEditable.d.ts.map +1 -0
  95. package/dist/util/isEditable.js +30 -0
  96. package/dist/util/isModifierKeyboardEvent.d.ts +2 -0
  97. package/dist/util/isModifierKeyboardEvent.d.ts.map +1 -0
  98. package/dist/util/isModifierKeyboardEvent.js +6 -0
  99. package/dist/util/isPrimaryKeyCode.d.ts +4 -0
  100. package/dist/util/isPrimaryKeyCode.d.ts.map +1 -0
  101. package/dist/util/isPrimaryKeyCode.js +6 -0
  102. package/dist/util/wrongModifierPressed.d.ts +3 -0
  103. package/dist/util/wrongModifierPressed.d.ts.map +1 -0
  104. package/dist/util/wrongModifierPressed.js +6 -0
  105. package/package.json +61 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { HotkeyContext as t } from "./context/HotkeyContext.js";
2
+ import { HotkeyProvider as x } from "./context/HotkeyProvider.js";
3
+ import { Hotkey as m } from "./definitions/Hotkey.js";
4
+ import { useHotkey as k } from "./hooks/useHotkey.js";
5
+ import { detectOS as H } from "./util/detectOS.js";
6
+ export {
7
+ m as Hotkey,
8
+ t as HotkeyContext,
9
+ x as HotkeyProvider,
10
+ H as detectOS,
11
+ k as useHotkey
12
+ };
@@ -0,0 +1,4 @@
1
+ import { HotKeyDefBase } from './HotKeyDefBase';
2
+ import { HotKeyDefChordBase } from './HotKeyDefChordBase';
3
+ export type HotKeyChordDef = HotKeyDefBase & HotKeyDefChordBase;
4
+ //# sourceMappingURL=HotKeyChordDef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotKeyChordDef.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyChordDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { HotKeyChordDef } from './HotKeyChordDef';
2
+ import { HotKeySequenceDef } from './HotKeySequenceDef';
3
+ export type HotKeyDef = HotKeyChordDef | HotKeySequenceDef;
4
+ //# sourceMappingURL=HotKeyDef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotKeyDef.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { HotkeyCallback } from './HotkeyCallback';
2
+ import { HotkeyOptions } from './HotkeyOptions';
3
+ import { HotkeyTextParts } from './HotkeyTextParts';
4
+ export type HotKeyDefBase = {
5
+ id: string;
6
+ callback: HotkeyCallback;
7
+ options: HotkeyOptions;
8
+ toString: () => string;
9
+ toParts: () => HotkeyTextParts;
10
+ };
11
+ //# sourceMappingURL=HotKeyDefBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotKeyDefBase.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDefBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,eAAe,CAAC;CAChC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { KeyValueType } from '../key/KeyValueType';
2
+ import { ModifierKeyCode } from '../key/ModifierKeyCode';
3
+ export type HotKeyDefChordBase = {
4
+ type: "chord";
5
+ resolve: KeyValueType;
6
+ primaryValue: string;
7
+ modifier: Record<Exclude<ModifierKeyCode, "Mod">, boolean>;
8
+ };
9
+ //# sourceMappingURL=HotKeyDefChordBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotKeyDefChordBase.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDefChordBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { PrimaryKey } from '../key/PrimaryKey';
2
+ export type HotKeyDefSequenceBase = {
3
+ type: "sequence";
4
+ keys: PrimaryKey[];
5
+ };
6
+ //# sourceMappingURL=HotKeyDefSequenceBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotKeyDefSequenceBase.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDefSequenceBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { HotKeyDefBase } from './HotKeyDefBase';
2
+ import { HotKeyDefSequenceBase } from './HotKeyDefSequenceBase';
3
+ export type HotKeySequenceDef = HotKeyDefBase & HotKeyDefSequenceBase;
4
+ //# sourceMappingURL=HotKeySequenceDef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotKeySequenceDef.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeySequenceDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type HotkeyCallback = (event: KeyboardEvent) => void;
2
+ //# sourceMappingURL=HotkeyCallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyCallback.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotkeyCallback.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * All options of an individual hotkey
3
+ */
4
+ export type HotkeyOptions = {
5
+ /**
6
+ * Determines if the default event of a key stroke should get prevented or not
7
+ * @default true
8
+ */
9
+ preventDefault: boolean;
10
+ /**
11
+ * Determines if the hotkey can be triggered while having an editable tag in focus (e.g. input)
12
+ * @default false
13
+ */
14
+ enableOnContentEditable: boolean;
15
+ /**
16
+ * Determines if the hotkey is actively listening
17
+ * @default false
18
+ */
19
+ disabled: boolean;
20
+ };
21
+ //# sourceMappingURL=HotkeyOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotkeyOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,uBAAuB,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type HotkeyTextParts = [string[], string];
2
+ //# sourceMappingURL=HotkeyTextParts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyTextParts.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotkeyTextParts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type HotKeyType = "chord" | "sequence";
2
+ //# sourceMappingURL=HotkeyType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyType.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotkeyType.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { useHotkey } from '../../hooks/useHotkey';
2
+ export type UseHotkeyFn = typeof useHotkey;
3
+ //# sourceMappingURL=UseHotkeyFn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseHotkeyFn.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/UseHotkeyFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,OAAO,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { HotKeyDefChordBase } from '../HotKeyDefChordBase';
2
+ export type ChordNode<Modifier extends string, Keys extends string> = {
3
+ readonly [K in Keys]: HotKeyDefChordBase;
4
+ } & {
5
+ readonly [K in Modifier]: ChordNode<Exclude<Modifier, K>, Keys>;
6
+ };
7
+ //# sourceMappingURL=ChordNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChordNode.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/ChordNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,MAAM,SAAS,CAAC,QAAQ,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,IAAI;IACpE,QAAQ,EAAE,CAAC,IAAI,IAAI,GAAG,kBAAkB;CACzC,GAAG;IACF,QAAQ,EAAE,CAAC,IAAI,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;CAChE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ModifierKeyCode } from '../../key/ModifierKeyCode';
2
+ import { PrimaryKeyCode } from '../../key/PrimaryKeyCode';
3
+ import { PrimaryKeyValue } from '../../key/PrimaryKeyValue';
4
+ import { ChordNode } from './ChordNode';
5
+ export type HotkeyChordBuilder = ChordNode<ModifierKeyCode, PrimaryKeyCode | PrimaryKeyValue>;
6
+ //# sourceMappingURL=HotkeyChordBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyChordBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/HotkeyChordBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,kBAAkB,GAAG,SAAS,CACxC,eAAe,EACf,cAAc,GAAG,eAAe,CACjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { HotKeyChordDef } from '../HotKeyChordDef';
2
+ export type IncompleteHotkey = {
3
+ hotkey: HotKeyChordDef;
4
+ timeoutId: number;
5
+ };
6
+ //# sourceMappingURL=IncompleteChordHotkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IncompleteChordHotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/IncompleteChordHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * All options regarding an entire hotkey scope
3
+ */
4
+ export type HotkeyProviderProps = {
5
+ /**
6
+ * Defines how many milliseconds can pass between two key presses in a sequence hotkey
7
+ * @default 400
8
+ */
9
+ sequenceTimeout?: number;
10
+ /**
11
+ * Defines how many milliseconds can pass from pressing a primary key until all required modifier keys are also pressed in a chord hotkey
12
+ * @default 100
13
+ */
14
+ chordTimeout?: number;
15
+ };
16
+ //# sourceMappingURL=HotkeyProviderProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyProviderProps.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/provider/HotkeyProviderProps.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PrimaryKey } from '../../key/PrimaryKey';
2
+ import { SequenceNode } from './SequenceNode';
3
+ export type HotkeySequenceBuilder = SequenceNode<PrimaryKey>;
4
+ //# sourceMappingURL=HotkeySequenceBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeySequenceBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/HotkeySequenceBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { HotKeyDefSequenceBase } from '../HotKeyDefSequenceBase';
2
+ export type SequenceNode<All extends string> = {
3
+ end: HotKeyDefSequenceBase;
4
+ } & {
5
+ readonly [K in All]: SequenceNode<All>;
6
+ };
7
+ //# sourceMappingURL=SequenceNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SequenceNode.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/SequenceNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,YAAY,CAAC,GAAG,SAAS,MAAM,IAAI;IAC7C,GAAG,EAAE,qBAAqB,CAAC;CAC5B,GAAG;IACF,QAAQ,EAAE,CAAC,IAAI,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;CACvC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { HotKeySequenceDef } from '../HotKeySequenceDef';
2
+ export type SequenceTree = {
3
+ hotkey: HotKeySequenceDef[];
4
+ keyBased: Partial<{
5
+ [key in string]: SequenceTree;
6
+ }>;
7
+ codeBased: Partial<{
8
+ [code in string]: SequenceTree;
9
+ }>;
10
+ };
11
+ //# sourceMappingURL=SequenceTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SequenceTree.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/SequenceTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;SACf,GAAG,IAAI,MAAM,GAAG,YAAY;KAC9B,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;SAChB,IAAI,IAAI,MAAM,GAAG,YAAY;KAC/B,CAAC,CAAC;CACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { KeyValueType } from './KeyValueType';
2
+ export type KeyDescription<T extends KeyValueType> = {
3
+ on: T;
4
+ value: string;
5
+ };
6
+ //# sourceMappingURL=KeyDescription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyDescription.d.ts","sourceRoot":"","sources":["../../../src/lib/types/key/KeyDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,YAAY,IAAI;IAAE,EAAE,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type KeyValueType = "code" | "key";
2
+ //# sourceMappingURL=KeyValueType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyValueType.d.ts","sourceRoot":"","sources":["../../../src/lib/types/key/KeyValueType.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ALL_MODIFIER_KEY_CODES } from '../../definitions/ModifierKeyCodes';
2
+ export type ModifierKeyCode = (typeof ALL_MODIFIER_KEY_CODES)[number];
3
+ //# sourceMappingURL=ModifierKeyCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModifierKeyCode.d.ts","sourceRoot":"","sources":["../../../src/lib/types/key/ModifierKeyCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PrimaryKeyCode } from './PrimaryKeyCode';
2
+ import { PrimaryKeyValue } from './PrimaryKeyValue';
3
+ export type PrimaryKey = PrimaryKeyValue | PrimaryKeyCode;
4
+ //# sourceMappingURL=PrimaryKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimaryKey.d.ts","sourceRoot":"","sources":["../../../src/lib/types/key/PrimaryKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type PrimaryKeyCode = "Zero" | "One" | "Two" | "Three" | "Four" | "Five" | "Six" | "Seven" | "Eight" | "Nine" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | "NumLock" | "Numpad0" | "Numpad1" | "Numpad2" | "Numpad3" | "Numpad4" | "Numpad5" | "Numpad6" | "Numpad7" | "Numpad8" | "Numpad9" | "NumpadAdd" | "NumpadDecimal" | "NumpadDivide" | "NumpadEnter" | "NumpadEqual" | "NumpadMultiply" | "NumpadSubtract" | "ArrowDown" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "CapsLock" | "Delete" | "End" | "Enter" | "Escape" | "Home" | "PageDown" | "PageUp" | "Tab" | "Backquote" | "Backslash" | "Backspace" | "BracketLeft" | "BracketRight" | "Comma" | "Equal" | "Minus" | "Period" | "Quote" | "Semicolon" | "Slash" | "Space";
2
+ //# sourceMappingURL=PrimaryKeyCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimaryKeyCode.d.ts","sourceRoot":"","sources":["../../../src/lib/types/key/PrimaryKeyCode.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,KAAK,GACL,KAAK,GACL,OAAO,GACP,MAAM,GACN,MAAM,GACN,KAAK,GACL,OAAO,GACP,OAAO,GACP,MAAM,GACN,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,eAAe,GACf,cAAc,GACd,aAAa,GACb,aAAa,GACb,gBAAgB,GAChB,gBAAgB,GAChB,WAAW,GACX,WAAW,GACX,YAAY,GACZ,SAAS,GACT,UAAU,GACV,QAAQ,GACR,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,UAAU,GACV,QAAQ,GACR,KAAK,GACL,WAAW,GACX,WAAW,GACX,WAAW,GACX,aAAa,GACb,cAAc,GACd,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,WAAW,GACX,OAAO,GACP,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type PrimaryKeyValue = "KeyZero" | "KeyOne" | "KeyTwo" | "KeyThree" | "KeyFour" | "KeyFive" | "KeySix" | "KeySeven" | "KeyEight" | "KeyNine" | "KeyA" | "KeyB" | "KeyC" | "KeyD" | "KeyE" | "KeyF" | "KeyG" | "KeyH" | "KeyI" | "KeyJ" | "KeyK" | "KeyL" | "KeyM" | "KeyN" | "KeyO" | "KeyP" | "KeyQ" | "KeyR" | "KeyS" | "KeyT" | "KeyU" | "KeyV" | "KeyW" | "KeyX" | "KeyY" | "KeyZ" | "KeyComma" | "KeyMinus" | "KeyEqual" | "KeyBackquote" | "KeyBackslash" | "KeyBracketLeft" | "KeyBracketRight" | "KeyPeriod" | "KeyQuote" | "KeySemicolon" | "KeySlash";
2
+ //# sourceMappingURL=PrimaryKeyValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimaryKeyValue.d.ts","sourceRoot":"","sources":["../../../src/lib/types/key/PrimaryKeyValue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,UAAU,GACV,UAAU,GACV,UAAU,GACV,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,WAAW,GACX,UAAU,GACV,cAAc,GACd,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { HotKeyChordDef } from '../types/hotkey/HotKeyChordDef';
2
+ export declare function checkModifierPressed(chord: HotKeyChordDef, event: KeyboardEvent): boolean;
3
+ //# sourceMappingURL=checkModifierPressed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkModifierPressed.d.ts","sourceRoot":"","sources":["../../src/lib/util/checkModifierPressed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,aAAa,GACnB,OAAO,CAOT"}
@@ -0,0 +1,6 @@
1
+ function f(i, e) {
2
+ return i.modifier.Shift === e.shiftKey && i.modifier.Control === e.ctrlKey && i.modifier.Alt === e.altKey && i.modifier.Meta === e.metaKey;
3
+ }
4
+ export {
5
+ f as checkModifierPressed
6
+ };
@@ -0,0 +1,3 @@
1
+ export type OS = "iOS/iPadOS" | "Android" | "Windows" | "macOS" | "Linux" | "Unknown";
2
+ export declare function detectOS(): OS;
3
+ //# sourceMappingURL=detectOS.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectOS.d.ts","sourceRoot":"","sources":["../../src/lib/util/detectOS.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,GACV,YAAY,GACZ,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,GACP,SAAS,CAAC;AAId,wBAAgB,QAAQ,IAAI,EAAE,CAkB7B"}
@@ -0,0 +1,11 @@
1
+ let e = null;
2
+ function i() {
3
+ if (e) return e;
4
+ if (typeof navigator > "u")
5
+ return e = "Unknown", e;
6
+ const n = (navigator.userAgent || "").toLowerCase();
7
+ return /iphone|ipad|ipod/.test(n) ? e = "iOS/iPadOS" : n.includes("android") ? e = "Android" : n.includes("windows") ? e = "Windows" : n.includes("mac os") ? e = "macOS" : n.includes("linux") ? e = "Linux" : e = "Unknown", e;
8
+ }
9
+ export {
10
+ i as detectOS
11
+ };
@@ -0,0 +1,2 @@
1
+ export declare function isClearKeydown(event: KeyboardEvent): boolean;
2
+ //# sourceMappingURL=isCleanKeydown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCleanKeydown.d.ts","sourceRoot":"","sources":["../../src/lib/util/isCleanKeydown.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,WAElD"}
@@ -0,0 +1,6 @@
1
+ function y(r) {
2
+ return !r.ctrlKey && !r.altKey && !r.metaKey && !r.shiftKey;
3
+ }
4
+ export {
5
+ y as isClearKeydown
6
+ };
@@ -0,0 +1,2 @@
1
+ export declare function isEditingKeystrokeContext(e: KeyboardEvent): boolean;
2
+ //# sourceMappingURL=isEditable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEditable.d.ts","sourceRoot":"","sources":["../../src/lib/util/isEditable.ts"],"names":[],"mappings":"AA0DA,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAMnE"}
@@ -0,0 +1,30 @@
1
+ function i(e) {
2
+ const t = e, r = (typeof t.composedPath == "function" ? t.composedPath() : null)?.find((s) => s instanceof Element) ?? null ?? e.target;
3
+ return r instanceof Element ? r : null;
4
+ }
5
+ function a(e) {
6
+ if (!(e instanceof HTMLInputElement)) return !1;
7
+ const t = (e.type || "").toLowerCase();
8
+ return t === "text" || t === "search" || t === "url" || t === "tel" || t === "email" || t === "password" || t === "number";
9
+ }
10
+ function c(e) {
11
+ if (!e) return !1;
12
+ const t = e.closest("[contenteditable]");
13
+ if (t && t.getAttribute("contenteditable") !== "false")
14
+ return !0;
15
+ const o = e.closest("textarea");
16
+ if (o instanceof HTMLTextAreaElement)
17
+ return !o.readOnly && !o.disabled;
18
+ const n = e.closest("input");
19
+ return n instanceof HTMLInputElement && a(n) ? !n.readOnly && !n.disabled : !!e.closest(
20
+ '[role="textbox"],[role="searchbox"],[role="combobox"],[role="spinbutton"]'
21
+ );
22
+ }
23
+ function l(e) {
24
+ if (e.isComposing) return !0;
25
+ const t = i(e);
26
+ return c(t);
27
+ }
28
+ export {
29
+ l as isEditingKeystrokeContext
30
+ };
@@ -0,0 +1,2 @@
1
+ export declare function isModifierKeyboardEvent(event: KeyboardEvent): boolean;
2
+ //# sourceMappingURL=isModifierKeyboardEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isModifierKeyboardEvent.d.ts","sourceRoot":"","sources":["../../src/lib/util/isModifierKeyboardEvent.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAOrE"}
@@ -0,0 +1,6 @@
1
+ function o(t) {
2
+ return t.code.startsWith("Meta") || t.code.startsWith("Shift") || t.code.startsWith("Alt") || t.code.startsWith("Control");
3
+ }
4
+ export {
5
+ o as isModifierKeyboardEvent
6
+ };
@@ -0,0 +1,4 @@
1
+ import { PrimaryKey } from '../types/key/PrimaryKey';
2
+ import { PrimaryKeyCode } from '../types/key/PrimaryKeyCode';
3
+ export declare function isPrimaryKeyCode(identifier: PrimaryKey): identifier is PrimaryKeyCode;
4
+ //# sourceMappingURL=isPrimaryKeyCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPrimaryKeyCode.d.ts","sourceRoot":"","sources":["../../src/lib/util/isPrimaryKeyCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,GACrB,UAAU,IAAI,cAAc,CAE9B"}
@@ -0,0 +1,6 @@
1
+ function t(r) {
2
+ return !r.startsWith("Key");
3
+ }
4
+ export {
5
+ t as isPrimaryKeyCode
6
+ };
@@ -0,0 +1,3 @@
1
+ import { HotKeyChordDef } from '../types/hotkey/HotKeyChordDef';
2
+ export declare function wrongModifierPressed(chord: HotKeyChordDef, event: KeyboardEvent): boolean;
3
+ //# sourceMappingURL=wrongModifierPressed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrongModifierPressed.d.ts","sourceRoot":"","sources":["../../src/lib/util/wrongModifierPressed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,aAAa,GACnB,OAAO,CAOT"}
@@ -0,0 +1,6 @@
1
+ function r(i, e) {
2
+ return !i.modifier.Shift && e.shiftKey || !i.modifier.Control && e.ctrlKey || !i.modifier.Alt && e.altKey || !i.modifier.Meta && e.metaKey;
3
+ }
4
+ export {
5
+ r as wrongModifierPressed
6
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "react-better-hotkeys",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "author": "Christopher Haindl",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/selokhq/react-better-hotkeys.git",
9
+ "directory": "packages/react-better-hotkeys"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "LICENSE",
14
+ "README.md"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./types/*": {
23
+ "types": "./dist/types/*.d.ts",
24
+ "default": "./dist/types/*.d.ts"
25
+ }
26
+ },
27
+ "scripts": {
28
+ "compile": "tsc -b",
29
+ "build": "npm run compile && vite build",
30
+ "test": "npm run build && tsc --project tsconfig.test.json && vitest",
31
+ "lint": "eslint . --fix",
32
+ "release": "release-it"
33
+ },
34
+ "peerDependencies": {
35
+ "react": ">=16.8.0",
36
+ "react-dom": ">=16.8.0"
37
+ },
38
+ "devDependencies": {
39
+ "@eslint/js": "9.37.0",
40
+ "@repo/eslint-config": "^0.0.0",
41
+ "@repo/typescript-config": "^0.0.0",
42
+ "@testing-library/jest-dom": "6.9.1",
43
+ "@testing-library/react": "16.3.0",
44
+ "@testing-library/user-event": "^14.6.1",
45
+ "@types/node": "24.7.2",
46
+ "@types/react": "19.2.2",
47
+ "@types/react-dom": "19.2.1",
48
+ "@vitejs/plugin-react": "5.0.4",
49
+ "eslint-plugin-react-hooks": "^7.0.1",
50
+ "eslint-plugin-react-refresh": "^0.4.24",
51
+ "globals": "16.4.0",
52
+ "jiti": "^2.6.1",
53
+ "jsdom": "27.0.0",
54
+ "typescript": "5.9.3",
55
+ "typescript-eslint": "^8.48.0",
56
+ "vite": "7.1.11",
57
+ "vite-plugin-dts": "4.5.4",
58
+ "vite-tsconfig-paths": "^6.0.1",
59
+ "vitest": "3.2.4"
60
+ }
61
+ }