We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a64c90 commit 7506ae6Copy full SHA for 7506ae6
1 file changed
12 - Key Sequence Detection/index.html
@@ -0,0 +1,35 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+ <meta charset="UTF-8">
5
+ <title>Key Detection</title>
6
+</head>
7
+<body>
8
+
9
+<script>
10
+ const keySequence = [
11
+ 'ArrowUp',
12
13
+ 'ArrowDown',
14
15
+ 'ArrowLeft',
16
+ 'ArrowRight',
17
18
19
+ 'b',
20
+ 'a',
21
+ ];
22
23
+ let userInput = new Array( keySequence.length );
24
25
+ window.addEventListener( 'keydown', ( { key } ) => {
26
+ userInput = [ ...userInput.slice( 1 ), key ];
27
28
+ if ( keySequence.every( ( v, k ) => v === userInput[ k ] ) ) {
29
+ alert( 'Yatta!' );
30
+ }
31
+ } );
32
+</script>
33
34
+</body>
35
+</html>
0 commit comments