We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0dacd44 commit 74150f6Copy full SHA for 74150f6
01 - JavaScript Drum Kit/index.html
@@ -63,9 +63,11 @@
63
const button = document.querySelector(`div[data-key="${key}"]`);
64
const sound = document.querySelector(`audio[data-key="${key}"]`);
65
66
- button.classList.add('playing');
+ if (!button) return;
67
+
68
+ sound.addEventListener('play', () => button.classList.add('playing'));
69
+ sound.addEventListener('ended', () => button.classList.remove('playing'));
70
sound.play();
- button.classList.remove('playing');
71
}
72
73
window.addEventListener('keypress', e => playDrum(e.keyCode));
0 commit comments