From 8410bb042fec8f1996e8bcecb85fadfbb414b3f9 Mon Sep 17 00:00:00 2001 From: Robert Hurst Date: Thu, 4 Jun 2020 22:29:17 -0700 Subject: [PATCH] fix: repair useKeyboardJs hook Fixed the importing of the KeyboardJS library with backward compatibility. Updated how bindings are set to prevent KeyboardJS from calling handlers repeatedly while holding keys. --- src/useKeyboardJs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/useKeyboardJs.ts b/src/useKeyboardJs.ts index 3ae5cc46..b1651ee7 100644 --- a/src/useKeyboardJs.ts +++ b/src/useKeyboardJs.ts @@ -6,7 +6,7 @@ const useKeyboardJs = (combination: string | string[]) => { const [keyboardJs, setKeyboardJs] = useState(null); useMount(() => { - import('keyboardjs').then(setKeyboardJs); + import('keyboardjs').then(k => setKeyboardJs(k.default || k)); }); useEffect(() => { @@ -16,7 +16,7 @@ const useKeyboardJs = (combination: string | string[]) => { const down = event => set([true, event]); const up = event => set([false, event]); - keyboardJs.bind(combination, down, up); + keyboardJs.bind(combination, down, up, true); return () => { keyboardJs.unbind(combination, down, up);