Skip to content

Commit

Permalink
fix: repair useKeyboardJs hook
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RobertWHurst committed Jun 8, 2020
1 parent 0fabbcd commit 8410bb0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/useKeyboardJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const useKeyboardJs = (combination: string | string[]) => {
const [keyboardJs, setKeyboardJs] = useState<any>(null);

useMount(() => {
import('keyboardjs').then(setKeyboardJs);
import('keyboardjs').then(k => setKeyboardJs(k.default || k));
});

useEffect(() => {
Expand All @@ -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);
Expand Down

0 comments on commit 8410bb0

Please sign in to comment.