Visitar URL original
recreated w/o video · wesbos/JavaScript30@4ccd969 · GitHub
Skip to content

Commit 4ccd969

Browse files
committed
recreated w/o video
1 parent 99b619d commit 4ccd969

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎01 - JavaScript Drum Kit/index-START.html‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,27 @@
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

6060
<script>
61+
6162
function playSound(e) {
62-
const audio= document.querySelector(`audio[data-key="${e.keyCode}"]`);
63-
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
64-
if(!audio) return;
65-
audio.currentTime = 0;
66-
audio.play();
67-
key.classList.add('playing');
68-
}
63+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
64+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
65+
if (!audio) return;
66+
audio.currentTime = 0;
67+
audio.play();
68+
key.classList.add('playing');
69+
}
6970

7071
function removeTransition(e) {
71-
if (e.propertyName !== 'transform') return;
72-
this.classList.remove('playing');
72+
if (e.propertyName !== "transform") return;
73+
this.classList.remove('playing');
7374
}
7475

75-
const keys = document.querySelectorAll('.key');
76+
77+
const keys= document.querySelectorAll(`.key`);
7678
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
7779

7880
window.addEventListener('keydown', playSound);
7981

80-
8182
</script>
8283

8384

0 commit comments

Comments
 (0)