forked from millxisyes/millxisyes.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
konami.js
45 lines (38 loc) · 739 Bytes
/
konami.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
/* i stole this */
var allowedKeys = {
37: "left",
38: "up",
39: "right",
40: "down",
65: "a",
66: "b"
};
var konamiCode = [
"up",
"up",
"down",
"down",
"left",
"right",
"left",
"right",
"b",
"a"
];
var konamiCodePosition = 0;
document.addEventListener("keydown", function(e) {
var key = allowedKeys[e.keyCode];
var requiredKey = konamiCode[konamiCodePosition];
if (key == requiredKey) {
konamiCodePosition++;
if (konamiCodePosition == konamiCode.length) {
activateCheats();
konamiCodePosition = 0;
}
} else {
konamiCodePosition = 0;
}
});
function activateCheats() {
alert("created with 💖 by slash - backslashg.com - it wasn't, i enslaved him - millx");
}