-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (28 loc) · 796 Bytes
/
script.js
File metadata and controls
33 lines (28 loc) · 796 Bytes
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
const keyUp = document.getElementById("keyUp");
const keyDown = document.getElementById("keyDown");
const mainContent = document.getElementById("mainContent");
let timer;
function scrollUp() {
mainContent.scrollTop += 250;
}
function scrollDown() {
mainContent.scrollTop -= 250;
}
keyUp.addEventListener("mousedown", () => {
timer = setInterval(scrollUp, 100);
});
keyUp.addEventListener("mouseup", () => {
if (timer) clearInterval(timer);
});
keyUp.addEventListener("mouseout", () => {
if (timer) clearInterval(timer);
});
keyDown.addEventListener("mousedown", () => {
timer = setInterval(scrollDown, 100);
});
keyDown.addEventListener("mouseup", () => {
if (timer) clearInterval(timer);
});
keyDown.addEventListener("mouseout", () => {
if (timer) clearInterval(timer);
});