-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound.js
42 lines (35 loc) · 896 Bytes
/
sound.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
let overlapAllowed = false;
function toggleOverlap() {
overlapAllowed = !overlapAllowed;
document.getElementById("overlapToggle").innerText = overlapAllowed ? "Overlapping On" : "Overlapping Off";
}
const audios = document.querySelectorAll('.Audio');
function stopAllAudio() {
audios.forEach(audio => {
audio.pause();
audio.currentTime = 0;
});
}
document.addEventListener('keydown', (event) => {
if (event.key.toLowerCase() === 's') {
stopAllAudio();
}
});
function playSound(id) {
if (!overlapAllowed) {
stopAllAudio();
}
const sound = document.getElementById(id);
sound.currentTime = 0;
sound.play();
}
document.addEventListener('keydown', (event) => {
if (event.key.toLowerCase() === 'enter') {
checkPassword();
}
});
document.addEventListener('keydown', (event) => {
if (event.key.toLowerCase() === 'escape') {
closeModal();
}
});