X Tutup
Skip to content

Commit 98952e4

Browse files
committed
finished Day 12
1 parent b5222f1 commit 98952e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

12 - Key Sequence Detection/index-START.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
</head>
88
<body>
99
<script>
10+
const pressed = [];
11+
const secretCode = 'wesbos';
12+
13+
window.addEventListener('keyup', (e) => {
14+
console.log(e.key);
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 DING!');
20+
cornify_add();
21+
}
22+
23+
console.log(pressed);
24+
});
1025
</script>
1126
</body>
1227
</html>

0 commit comments

Comments
 (0)
X Tutup