| 7 | import drumSfx from '../sounds/909-drums.mp3'; |
| 8 | |
| 9 | const useKeyboardBindings = map => { |
| 10 | React.useEffect(() => { |
| 11 | const handlePress = ev => { |
| 12 | const handler = map[ev.key]; |
| 13 | |
| 14 | if (typeof handler === 'function') { |
| 15 | handler(); |
| 16 | } |
| 17 | }; |
| 18 | |
| 19 | window.addEventListener('keydown', handlePress); |
| 20 | |
| 21 | return () => { |
| 22 | window.removeEventListener('keydown', handlePress); |
| 23 | }; |
| 24 | }, [map]); |
| 25 | }; |
| 26 | |
| 27 | function DrumMachine() { |
| 28 | const [play] = useSound(drumSfx, { |
no outgoing calls
no test coverage detected
searching dependent graphs…