File tree 1 file changed +7
-1
lines changed
exercises/01 - JavaScript Drum Kit
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 75
75
76
76
keyelement . classList . add ( 'playing' ) ;
77
77
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 ;
79
82
80
83
soundclip . play ( ) ; // Play sound
81
84
}
89
92
// Find all elements in the document with a class 'key'
90
93
const keys = document . querySelectorAll ( '.key' ) ;
91
94
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)
92
98
window . addEventListener ( 'keydown' , playSound ) ;
93
99
94
100
keys . forEach ( key =>
You can’t perform that action at this time.
0 commit comments