We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f04fa97 commit 5ca3a3fCopy full SHA for 5ca3a3f
01 - JavaScript Drum Kit/index.html
@@ -58,7 +58,8 @@
58
<audio data-key="76" src="sounds/tink.wav"></audio>
59
60
<script>
61
- window.addEventListener('keydown', function(e){
+
62
+ function playSound(e){
63
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
64
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
65
if (!audio) return;
@@ -73,8 +74,8 @@
73
74
}
75
const keys = document.querySelectorAll('.key');
76
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
- } );
77
-
+ }
78
+ window.addEventListener('keydown', playSound );
79
</script>
80
81
0 commit comments