File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
exercises/01 - JavaScript Drum Kit Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 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 }
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 =>
You can’t perform that action at this time.
0 commit comments