Skip to content

Commit 3220bb6

Browse files
committed
Update Exercise 1
Rewrites should probably start from the beginning
1 parent 590a28a commit 3220bb6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

exercises/01 - JavaScript Drum Kit/index.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@
7575

7676
keyelement.classList.add('playing');
7777

78-
soundclip.currentTime = 0;
78+
// Ensures that the sound clip always plays from the beginning. Otherwise,
79+
// if the 'a' key is pressed twice rapidly, the soundclip will only play through
80+
// once.
81+
soundclip.currentTime = 0;
7982

8083
soundclip.play(); // Play sound
8184
}
@@ -89,6 +92,9 @@
8992
// Find all elements in the document with a class 'key'
9093
const keys = document.querySelectorAll('.key');
9194

95+
// Listen for any `keydown` events that occur on this browser window instance (this page)
96+
// When a `keydown` event is observered, trigger the `playSound` function, passing in the
97+
// `keydown` event as the argument (e)
9298
window.addEventListener('keydown', playSound);
9399

94100
keys.forEach(key =>

0 commit comments

Comments
 (0)