From 409c46542c02eef604c458447ea76fa0304404bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=84=EA=B7=BC?= Date: Thu, 9 Jun 2022 23:47:52 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8C=20(#9)=20-=20implemt=20space=20to?= =?UTF-8?q?=20play=20pause=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ContentController/index.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/ContentController/index.tsx b/src/components/ContentController/index.tsx index 7fa84c0..dd31805 100644 --- a/src/components/ContentController/index.tsx +++ b/src/components/ContentController/index.tsx @@ -59,13 +59,9 @@ const ContentController = () => { const onSpaceDown = useCallback( (e: KeyboardEvent) => { - if ( - e.key === "Space" && - !e.shiftKey && - !e.ctrlKey && - !e.metaKey && - !e.altKey - ) { + if (e.code === "Space") { + console.log("123"); + e.stopPropagation(); e.preventDefault(); @@ -85,10 +81,10 @@ const ContentController = () => { useEffect(() => { if (!controlDisable) { - document.addEventListener("keypress", onSpaceDown); + window.addEventListener("keydown", onSpaceDown); return () => { - document.removeEventListener("keypress", onSpaceDown); + window.removeEventListener("keydown", onSpaceDown); }; } }, [controlDisable, onSpaceDown]);