-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (18 loc) · 684 Bytes
/
app.js
File metadata and controls
21 lines (18 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// set variables
let keyCount = 0;
const konamiCode = ["Filler", "ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "KeyB", "KeyA", "Enter"];
window.addEventListener('keyup', function(e) {
keyCount++;
if (e.code != konamiCode[keyCount]) {
// pattern mismatch, reset the count
keyCount = 0;
} else {
if (keyCount == 11) {
// full Konami Code entered!
// change the next line of code to do whatever it is you want to trigger
console.log("KONAMI!");
// leave this so the trigger can be hit multiple times
keyCount = 0;
}
}
})