Skip to content

Commit dd77f10

Browse files
committed
files outside folder😅
1 parent f232509 commit dd77f10

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

index.html renamed to 01 - JavaScript Drum Kit/index.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@
5858
<audio data-key="74" src="sounds/snare.wav"></audio>
5959
<audio data-key="75" src="sounds/tom.wav"></audio>
6060
<audio data-key="76" src="sounds/tink.wav"></audio>
61-
6261
<script>
62+
// We will listen to the event of the keys pressed
63+
window.addEventListener('keydown', (e) => {
64+
// We get the element that matches the key pressed
65+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
66+
console.log(audio);
67+
if (!audio) return; // Stop function from running all together
68+
audio.play();
69+
})
6370
</script>
6471

6572

01 - JavaScript Drum Kit/sounds/caca.jpg

Loading

yvette-de-wit-NYrVisodQ2M-unsplash.jpg renamed to 01 - JavaScript Drum Kit/yvette-de-wit-NYrVisodQ2M-unsplash.jpg

File renamed without changes.

0 commit comments

Comments
 (0)