Skip to content

Commit fd62ffa

Browse files
author
Justin Ramel
committed
drumkit 1st try - blind
1 parent 61b13da commit fd62ffa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

01 - JavaScript Drum Kit/index-START.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

6060
<script>
61-
61+
document.body.onkeydown = function(e){
62+
var key = document.querySelector(`.key[data-key="${e.which}"]`)
63+
var audio = document.querySelector(`audio[data-key="${e.which}"]`)
64+
audio.play()
65+
key.classList.add('playing')
66+
setTimeout(() => key.classList.remove('playing'), 60)
67+
}
6268
</script>
6369

6470

0 commit comments

Comments
 (0)