Skip to content

Commit 12bb6b8

Browse files
committed
added solution for KONAMI code (sequence detection)
1 parent 708bfe2 commit 12bb6b8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

12 - Key Sequence Detection/index-START.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
</head>
88
<body>
99
<script>
10+
11+
const pressed = [];
12+
const secretCode = 'razvan';
13+
14+
window.addEventListener('keyup', (e) => {
15+
pressed.push(e.key);
16+
pressed.splice(-secretCode.length - 1, pressed.length - secretCode.length)
17+
18+
if (pressed.join('').includes(secretCode)) {
19+
console.log('Ding');
20+
cornify_add();
21+
}
22+
console.log(pressed);
23+
})
1024
</script>
1125
</body>
1226
</html>

0 commit comments

Comments
 (0)