-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (53 loc) · 1.4 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
"use strict";
let i = 0;
let colors = [
"dodgerblue",
"green",
"blue",
"lightcyan",
"yellow",
"pink",
"cyan",
"lime",
"black",
"silver",
"greenyellow",
"maroon",
"indianred",
"navy",
"aqua",
"aliceblue",
"darkgreen",
"aquamarine",
"azure",
"cadetblue",
"chocolate",
"coral",
"darkgreen",
"darkmagenta",
"darkorange",
"darkorchid",
"darkseagreen",
"darkslategrey",
"dodgerblue",
"fuchsia",
];
let pressedkey = document.addEventListener("keydown", function (e) {
// console.log(e.key);
document.querySelector(".pressedKey").style.color = "white";
document.querySelector(".pressedKey").textContent = e.key;
i++;
document.querySelector(".highscore").textContent = i;
let randomColorID = Math.trunc(Math.random() * colors.length);
document.querySelector("body").style.backgroundColor = colors[randomColorID];
});
let randomColorID, randomTextID;
let tap = document.addEventListener("click", function () {
document.querySelector(".pressedKey").textContent = "TAP";
i++;
document.querySelector(".highscore").textContent = i;
randomTextID = Math.trunc(Math.random() * colors.length);
randomColorID = Math.trunc(Math.random() * colors.length);
document.querySelector("body").style.backgroundColor = colors[randomColorID];
document.querySelector(".pressedKey").style.color = colors[randomTextID];
});