Skip to content

Commit 6eac3b1

Browse files
author
=
committed
JS30 wesbos#12 completed
1 parent ed27d27 commit 6eac3b1

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

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

0 commit comments

Comments
 (0)