-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
113 lines (100 loc) · 2.54 KB
/
konami.html
File metadata and controls
113 lines (100 loc) · 2.54 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
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Konami Code</title>
</head>
<body>
<h1>Konami Code</h1>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossOrigin="anonymous"></script>
<script>
"use strict";
// First attempt
// $(document).keyup(function (event) {
// console.log(event.keys);
// });
// var allowedKeys = {
// //key log
// 37: 'left',
// 38: 'up',
// 39: 'right',
// 40: 'down',
// 65: 'a',
// 66: 'b',
// 13: 'enter'
// };
// // code sequence
// var konamiCode = ['up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a', 'enter'];
//
// // (position) user position
// var konamiCodePosition = 0;
// document.addEventListener('keydown', function (e) {
// var key = allowedKeys[e.keys];
// var requiredKey = konamiCodePosition
// if (key === requiredKey) {
// konamiCodePosition++;
//
// if (konamiCodePosition === konamiCode.length) {
// activateCheats();
// konamiCodePosition = 0;
// }
// } else {
// konamiCodePosition = 0;
// }
// });
let keyCombo = []
$(document).keyup(function(event){
if(event.key === "ArrowUp") {
keyCombo.push(event.key)
console.log(keyCombo)
}
if(event.key === "ArrowDown") {
keyCombo.push(event.key)
console.log(keyCombo)
}
if(event.key === "ArrowLeft") {
keyCombo.push(event.key)
console.log(keyCombo)
}
if(event.key === "ArrowRight") {
keyCombo.push(event.key)
console.log(keyCombo)
}
if(event.key === "b") {
keyCombo.push(event.key)
console.log(keyCombo)
}
if(event.key === "a") {
keyCombo.push(event.key)
console.log(keyCombo)
}
});
function change (arr) {
console.log(arr.join(''));
let arrString = arr.join('')
if(arrString === 'ArrowUpArrowUpArrowDownArrowDownArrowLeftArrowRightArrowLeftArrowRightba') {
return true
}
}
$(document).keyup(function(event) {
if (event.key === "Enter") {
if(change(keyCombo) === true) {
document.body.style.background = "lightgrey";
// var audio = new Audio('');
alert("Always Smile!");
} else {
while(keyCombo.length){
keyCombo.shift();
console.log(keyCombo);
}
}
}
});
</script>
<!--<script src="https://code.jquery.com/jquery-2.2.4.min.js"-->
<!-- integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossOrigin="anonymous"></script>-->
</body>
</html>