forked from acidsound/band4all
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drum.js
24 lines (24 loc) · 879 Bytes
/
drum.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
document.addEventListener("DOMContentLoaded", function () {
document
.querySelector(".modal>.dialog>.btnOk")
.addEventListener("click", async () => {
document.querySelector(".modal").classList.add("hidden");
context.state === "suspended" && (await context.resume());
console.log("audioContext state", context.state);
for (let downEvent of ["keydown"]) {
//, 'mousedown', 'touchstart']
window.addEventListener(downEvent, function (e) {
const key = keyMap[e.which] || e.target.getAttribute("data-note");
playDrum(1, key);
});
}
["keyup"].map((
upEvent //, 'mouseup', 'touchend']
) =>
window.addEventListener(upEvent, function (e) {
const key = keyMap[e.which] || e.target.getAttribute("data-note");
playDrum(0, key);
})
);
});
});