-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
98 lines (81 loc) · 2.38 KB
/
script.js
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
94
95
96
97
98
const ride = document.querySelector('#ride')
ride.addEventListener('click',() =>{
let rideSound = new Audio('ride.wav');
rideSound.play();
});
const crash = document.querySelector('#crash')
crash.addEventListener('click',() =>{
let crashSound = new Audio('crash.wav');
crashSound.play();
});
const hat = document.querySelector('#hat')
hat.addEventListener('click',() =>{
let hatSound = new Audio('hi-hat.wav');
hatSound.play();
});
const bass = document.querySelector('#bass')
bass.addEventListener('click',() =>{
let bassSound = new Audio('bass-drum.wav');
bassSound.play();
});
const hiTom = document.querySelector('#hiTom')
hiTom.addEventListener('click',() =>{
let hiTomSound = new Audio('high-tom.wav');
hiTomSound.play();
});
const middleTom = document.querySelector('#middleTom')
middleTom.addEventListener('click',() =>{
let middleTomSound = new Audio('medium-tom.wav');
middleTomSound.play();
});
const snare = document.querySelector('#snare')
snare.addEventListener('click',() =>{
let snareSound = new Audio('snare.wav');
snareSound.play();
});
const floorTom = document.querySelector('#floorTom')
floorTom.addEventListener('click',() =>{
let floorTomSound = new Audio('floor-tom.wav');
floorTomSound.play();
});
const floorTom2 = document.querySelector('#floorTom2')
floorTom2.addEventListener('click',() =>{
let floorTom2Sound = new Audio('floor-tom.wav');
floorTom2Sound.play();
});
document.addEventListener('keyup', (event1) => {
let code = event1.code
if (code === 'Digit1') {
let rideSound = new Audio('ride.wav');
rideSound.play();
} else if (code === 'Digit2') {
let crashSound = new Audio('crash.wav');
crashSound.play();
}
else if (code === 'Digit3') {
let hatSound = new Audio('hi-hat.wav');
hatSound.play();
}
else if (code === 'Digit4') {
let bassSound = new Audio('bass-drum.wav');
bassSound.play();
}
else if (code === 'Digit5') {
let hiTomSound = new Audio('high-tom.wav');
hiTomSound.play();
}
else if (code === 'Digit6') {
let middleTomSound = new Audio('medium-tom.wav');
middleTomSound.play();
}
else if (code === 'Digit7') {
let snareSound = new Audio('snare.wav');
snareSound.play();
}
else if (code === 'Digit8') {
let floorTomSound = new Audio('floor-tom.wav');
floorTomSound.play();
} else {
alert('Enter a number between 1 & 8')
}
})