Visitar URL original
JS30 #12 complete · DeonJordaan/JavaScript30@4d622bf · GitHub
Skip to content

Commit 4d622bf

Browse files
committed
JS30 wesbos#12 complete
1 parent 5d01926 commit 4d622bf

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
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="https://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
7+
type="text/javascript"
8+
src="https://www.cornify.com/js/cornify.js"
9+
></script>
10+
</head>
11+
<body>
12+
<script>
13+
const pressed = [];
14+
const secretCode = 'lavinia';
15+
16+
window.addEventListener('keyup', (e) => {
17+
console.log(e.key);
18+
pressed.push(e.key);
19+
20+
pressed.splice(
21+
-secretCode.length - 1,
22+
pressed.length - secretCode.length
23+
);
24+
25+
if (pressed.join('').includes(secretCode)) {
26+
console.log('DING-DING!');
27+
cornify_add();
28+
}
29+
});
30+
</script>
31+
</body>
1232
</html>

0 commit comments

Comments
 (0)