Skip to content

Commit 6cd9b22

Browse files
committed
twelve complete
1 parent ef0b92a commit 6cd9b22

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

12 - Key Sequence Detection/index-START.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
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+
//negative will take it from the end of the array
18+
19+
if(pressed.join('').includes(secretCode)){
20+
console.log('yep!');
21+
cornify_add();
22+
//will give you random unicorns on the screen!
23+
}
24+
25+
console.log(pressed);
26+
})
1027
</script>
1128
</body>
1229
</html>

0 commit comments

Comments
 (0)