Skip to content

Commit 784f30d

Browse files
author
Richard Hart
committed
Day 12
1 parent 497d794 commit 784f30d

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<!DOCTYPE html>
22
<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-
</script>
11-
</body>
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 = 'richard';
12+
window.addEventListener('keyup', (e) => {
13+
pressed.push(e.key);
14+
pressed.splice(-secretCode.length - 1, pressed.length - secretCode.length);
15+
16+
if(pressed.join('').includes(secretCode)) {
17+
console.log('MATCH');
18+
}
19+
});
20+
</script>
21+
</body>
1222
</html>

0 commit comments

Comments
 (0)