-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
46 lines (39 loc) · 777 Bytes
/
konami.html
File metadata and controls
46 lines (39 loc) · 777 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
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
</head>
<body>
<h1>Konami Code</h1>
<script>
"use strict";
const konamiCode = [
"ArrowUp",
"ArrowUp",
"ArrowDown",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowLeft",
"ArrowRight",
"b",
"a",
"Enter"
];
let konamiCodeIndex = 0;
document.addEventListener("keyup", event => {
if (event.key === konamiCode[konamiCodeIndex]) {
konamiCodeIndex++;
if (konamiCodeIndex === konamiCode.length) {
// Konami Code entered successfully
document.body.style.backgroundColor = "blue";
alert("You have added 30 lives!")
konamiCodeIndex = 0;
}
} else {
konamiCodeIndex = 0;
}
});
</script>
</body>
</html>