Skip to content

Commit 5fd7d94

Browse files
committed
Get audio to play for corresp keyCode
1 parent c2107e3 commit 5fd7d94

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

01 - JavaScript Drum Kit/index-START.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959

6060
<script>
6161
window.addEventListener('keydown', function(e) {
62-
console.log(e.keyCode)
62+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
63+
console.log(audio)
64+
if(!audio) return; //stop function all together
65+
audio.play();
6366
});
6467
</script>
6568

0 commit comments

Comments
 (0)