react-hotkeys-hook 4.0.0-5 → 4.0.0-6

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.
@@ -0,0 +1,3 @@
1
+ export declare function isHotkeyPressed(key: string | string[], splitKey?: string): boolean;
2
+ export declare function pushToCurrentlyPressedKeys(key: string | string[]): void;
3
+ export declare function removeFromCurrentlyPressedKeys(key: string | string[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hotkeys-hook",
3
- "version": "4.0.0-5",
3
+ "version": "4.0.0-6",
4
4
  "repository": "https://JohannesKlauss@github.com/JohannesKlauss/react-keymap-hook.git",
5
5
  "homepage": "https://johannesklauss.github.io/react-hotkeys-hook/",
6
6
  "author": "Johannes Klauss",
@@ -2,6 +2,15 @@ import { Hotkey, KeyboardModifiers, Keys } from './types'
2
2
 
3
3
  const reservedModifierKeywords = ['ctrl', 'shift', 'alt', 'meta', 'mod']
4
4
 
5
+ const mappedKeys: Record<string, string> = {
6
+ esc: 'escape',
7
+ return: 'enter',
8
+ left: 'arrowleft',
9
+ up: 'arrowup',
10
+ right: 'arrowright',
11
+ down: 'arrowdown',
12
+ }
13
+
5
14
  export function parseKeysHookInput(keys: Keys, splitKey: string = ','): string[] {
6
15
  if (typeof keys === 'string') {
7
16
  return keys.split(splitKey)
@@ -15,8 +24,7 @@ export function parseHotkey(hotkey: string, combinationKey: string = '+'): Hotke
15
24
  .toLocaleLowerCase()
16
25
  .split(combinationKey)
17
26
  .map(k => k.trim())
18
- .map(k => k === 'esc' ? 'escape' : k)
19
- .map(k => k === 'return' ? 'enter' : k)
27
+ .map(k => mappedKeys[k] || k)
20
28
 
21
29
  const modifiers: KeyboardModifiers = {
22
30
  alt: keys.includes('alt'),