Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a094cd3

Browse files
committed
added a secret code and keypress listener
1 parent 345135a commit a094cd3

File tree

3 files changed

+21
-37
lines changed

3 files changed

+21
-37
lines changed

12 - Key Sequence Detection/index-FINISHED.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

12 - Key Sequence Detection/index-START.html

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 secretCode = 'qwerty';
11+
let userEntry = [];
12+
13+
window.addEventListener('keyup', (e) => {
14+
userEntry.push(e.key);
15+
userEntry.splice(-secretCode.length - 1, userEntry.length - secretCode.length);
16+
17+
userEntry.join('') === secretCode ? cornify_add() : null;
18+
});
19+
</script>
20+
</body>
21+
</html>

0 commit comments

Comments
 (0)