소스 검색

Reduce conditions to one line

cihat 2 년 전
부모
커밋
886437985d
1개의 변경된 파일2개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 6
      src/hooks/useKeyPress.tsx

+ 2 - 6
src/hooks/useKeyPress.tsx

@@ -4,14 +4,10 @@ const useKeyPress = (targetKey) => {
   const [keyPressed, setKeyPressed] = React.useState(false);
 
   function downHandler({ key }) {
-    if (key === targetKey) {
-      setKeyPressed(true);
-    }
+    if (key === targetKey) setKeyPressed(true);
   }
   const upHandler = ({ key }) => {
-    if (key === targetKey) {
-      setKeyPressed(false);
-    }
+    if (key === targetKey) setKeyPressed(false);
   };
   React.useEffect(() => {
     window.addEventListener("keydown", downHandler);