Explorar o código

Reduce conditions to one line

cihat %!s(int64=2) %!d(string=hai) anos
pai
achega
886437985d
Modificáronse 1 ficheiros con 2 adicións e 6 borrados
  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);