Skip to content

Commit f743a12

Browse files
committed
Day 12 - Key detection and Unicorns
1 parent 046737a commit f743a12

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Key Detection</title>
6+
<script type="text/javascript" src="http://www.cornify.com/js/cornify.js"></script>
7+
</head>
8+
<body>
9+
<script>
10+
const pressed = [];
11+
const secretCode = 'secret';
12+
13+
14+
15+
window.addEventListener('keyup', (e) => {
16+
console.log(e.key);
17+
pressed.push(e.key);
18+
pressed.splice(-secretCode.length - 1, pressed.length - secretCode.length);
19+
if (pressed.join('').includes(secretCode)) {
20+
console.log('DING DING!');
21+
cornify_add();
22+
}
23+
24+
});
25+
26+
</script>
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)