-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_start.html
93 lines (90 loc) · 1.98 KB
/
index_start.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS Drumkit</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p style="text-align:center;color: rgb(240, 239, 238); margin-top: 6rem;font-family:serif;font-weight: bolder;font-size:50px"> 🎼BEAT the BEAT!🎧</p>
<div class="keys">
<div class="key" id="65">
<p>A</p>
<span class="sound">
Clap
</span>
</div>
<div class="key" id="83">
<p>S</p>
<span class="sound">
Hihat
</span>
</div>
<div class="key" id="68">
<p>D</p>
<span class="sound">
Kick
</span>
</div>
<div class="key" id="70">
<p>F</p>
<span class="sound">
Openhat
</span>
</div>
<div class="key" id="71">
<p>G</p>
<span class="sound">
Boom
</span>
</div>
<div class="key" id="72">
<p>H</p>
<span class="sound">
Ride
</span>
</div>
<div class="key" id="74">
<p>J</p>
<span class="sound">
Snare
</span>
</div>
<div class="key" id="75">
<p>K</p>
<span class="sound">
Tom
</span>
</div>
<div class="key" id="76">
<p>L</p>
<span class="sound">
Tink
</span>
</div>
</div>
<audio id="a65" src="sounds/clap.wav"></audio>
<audio id="a83" src="sounds/hihat.wav"></audio>
<audio id="a68" src="sounds/kick.wav"></audio>
<audio id="a70" src="sounds/openhat.wav"></audio>
<audio id="a71" src="sounds/boom.wav"></audio>
<audio id="a72" src="sounds/ride.wav"></audio>
<audio id="a74" src="sounds/snare.wav"></audio>
<audio id="a75" src="sounds/tom.wav"></audio>
<audio id="a76" src="sounds/tink.wav"></audio>
<script>
function playSound(e){
var audio= document.querySelector(`audio[id="a${e.keyCode}"]`)
var key=document.querySelector(`div[id="${e.keyCode}"]`)
if (!audio) return;
key.classList.add("playing");
audio.currentTime=0;
audio.play();
setTimeout(function(){
key.classList.remove('playing');
},70);
}
window.addEventListener('keydown', playSound)
</script>
</body>
</html>