MCPcopy Create free account
hub / github.com/codemistic/Web-Development / playSound

Function playSound

jsdrum/main.js:15–23  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

13 }
14
15function playSound(e) {
16 const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
17 const key = document.querySelector(`div[data-key="${e.keyCode}"]`);
18 if (!audio) return;
19
20 key.classList.add('playing'); //changing the class of key div
21 audio.currentTime = 0; // it starts the music before the end of previous music
22 audio.play();
23 }
24
25 // the e represents event , here the key of keyboard keyCode is the property of event e
26

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected