Skip to content

Commit 2f61a47

Browse files
committed
working through project wesbos#1
1 parent 30a4137 commit 2f61a47

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"type": "chrome",
10+
"request": "launch",
11+
"name": "Launch Chrome against localhost",
12+
"url": "http://localhost:8080",
13+
"webRoot": "${workspaceFolder}"
14+
}
15+
]
16+
}

01 - JavaScript Drum Kit/index-START.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,16 @@
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

6060
<script>
61-
61+
window.addEventListener('keydown', function(e) { //adds a listener for the button
62+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
63+
console.log(audio); //stops the function from running all together
64+
if(!audio) return;
65+
audio.currentTime = 0; //rewind to the start after each cycle through
66+
audio.play();
67+
})
6268
</script>
6369

6470

6571
</body>
6672
</html>
73+

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)