Browse Source

Allow playing/pausing with spacebar

master
Dylan Baker 4 years ago
parent
commit
05e950922f
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/Controls.tsx

+ 9
- 1
src/Controls.tsx View File

1
-import React from 'react';
1
+import React, { useEffect } from 'react';
2
 
2
 
3
 interface Props {
3
 interface Props {
4
   running: boolean;
4
   running: boolean;
33
     }
33
     }
34
   };
34
   };
35
 
35
 
36
+  useEffect(() => {
37
+    document.addEventListener('keyup', (e) => {
38
+      if (e.key === ' ') {
39
+        toggle();
40
+      }
41
+    });
42
+  }, [toggle]);
43
+
36
   return (
44
   return (
37
     <div className="controls">
45
     <div className="controls">
38
       <div className="controls__section dimensions">
46
       <div className="controls__section dimensions">

Loading…
Cancel
Save