-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
111 lines (83 loc) · 2.17 KB
/
konami.html
File metadata and controls
111 lines (83 loc) · 2.17 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<title>Konami Code</title>
<script
src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="
crossorigin="anonymous"></script>
<style>
body {
background-color: #C6D8D3;
padding: 30px;
}
h1, p {
font-family: sans-serif;
}
h1 {
font-size: 76px;
color: #5B6361;
}
p {
font-size: 24px;
color: #353A39;
cursor: pointer;
margin-bottom: 3em;
}
</style>
</head>
<body>
<div id="container">
<h1>Konami Code</h1>
<p>click here to enter code</p>
</div>
<script src="/js/jquery.js"></script>
<script>
"use strict";
let keys = {
37: "left",
38: "up",
39: "right",
40: "down",
65: "a",
66: "b",
}
let konamiCode = ["up", "up", "down", "down", "left", "right", "left", "right", "b", "a",]
document.addEventListener("keydown", checkCode, false);
let keyCount = 0;
let timerID;
function checkCode(event) {
// console.log(event.keyCode)
let keyPressed = keys[event.keyCode]
if (keyPressed === konamiCode[keyCount]) {
keyCount++
window.clearTimeout(timerID);
timerID = window.setTimeout(resetKeyState, 1000);
if (keyCount === konamiCode.length) {
cheatCodeActivated();
resetKeyState();
}
} else {
resetKeyState();
}
}
function cheatCodeActivated() {
alert("You have added 30 lives!");
}
function resetKeyState() {
console.log("Resetting state")
keyCount = 0
window.clearTimeout(timerID);
}
// $(document).keyup(function(event){
// // console.log(event.keyCode);
//
//
// var keycode = ArrowUpArrowUpArrowDownArrowDownArrowLeftArrowRightArrowLeftArrowRightbaEnter
//
//
//
// })
</script>
</body>
</html>