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 2797c13 commit fc9030bCopy full SHA for fc9030b
01 - JavaScript Drum Kit/index-PROGRESS.html
@@ -58,9 +58,12 @@
58
<audio data-key="76" src="sounds/tink.wav"></audio>
59
60
<script>
61
-window.addEventListener("keydown"), function(e) {
62
- console.log(e);
63
-}
+window.addEventListener("keydown", function(e) {
+ const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
+ if (!audio) return; // will stop the function from running.
64
+ console.log(audio);
65
+ audio.play();
66
+});
67
</script>
68
69
0 commit comments