File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed
Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 5858 < audio data-key ="76 " src ="sounds/tink.wav "> </ audio >
5959
6060< script >
61+ window . addEventListener ( 'keydown' , function ( e ) {
62+ playSound ( e ) ;
63+ } ) ;
6164
65+ function playSound ( e ) {
66+ const audio = document . querySelector ( `audio[data-key="${ e . keyCode } "]` ) ;
67+ const key = document . querySelector ( `.key[data-key="${ e . keyCode } "]` ) ;
68+ if ( ! audio ) return ;
69+ audio . currentTime = 0 ;
70+ audio . play ( ) ;
71+ key . classList . add ( 'playing' ) ;
72+ }
73+
74+ const keys = document . querySelectorAll ( '.key' ) ;
6275</ script >
6376
6477
Original file line number Diff line number Diff line change 11html {
22 font-size : 10px ;
3- background : url (http://i.imgur.com/b9r5sEL .jpg) bottom center;
3+ background : url (http://0.0.0.0:8000/images/pantydogs .jpg) bottom center;
44 background-size : cover;
55}
66body , html {
You can’t perform that action at this time.
0 commit comments