diff --git a/src/__stories__/useKeyPressEvent.story.tsx b/src/__stories__/useKeyPressEvent.story.tsx index 4930bf0500..0e85a6f47a 100644 --- a/src/__stories__/useKeyPressEvent.story.tsx +++ b/src/__stories__/useKeyPressEvent.story.tsx @@ -16,7 +16,7 @@ const Demo = () => { }; const reset = () => setCount(() => 0); - useKeyPressEvent(']', increment, increment); + useKeyPressEvent(']', increment); useKeyPressEvent('[', decrement, decrement); useKeyPressEvent('r', reset); diff --git a/src/useKeyPressEvent.ts b/src/useKeyPressEvent.ts index 9a87105224..07b9d15ea2 100644 --- a/src/useKeyPressEvent.ts +++ b/src/useKeyPressEvent.ts @@ -11,7 +11,7 @@ const useKeyPressEvent = ( const [pressed, event] = useKeyPress(key); useUpdateEffect(() => { if (!pressed && keyup) keyup(event!); - else if (keydown) keydown(event!); + else if (pressed && keydown) keydown(event!); }, [pressed]); };