Skip to content

Commit c5bf623

Browse files
committed
first commit
1 parent b56c911 commit c5bf623

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed
12 KB
Binary file not shown.
198 KB
Loading

01 - JavaScript Drum Kit/index-START.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,20 @@
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

01 - JavaScript Drum Kit/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
html {
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
}
66
body,html {

0 commit comments

Comments
 (0)