File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed
12-key-sequence-detection Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Key sequence detection
2
+ Watch this challenge live in [ codepen] ( http://codepen.io/pouyio/full/vywmwQ/ ) .
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title > Key sequence detection</ title >
6
+ < style media ="screen ">
7
+ body {
8
+ font-family : sans-serif;
9
+ font-size : 1.8em ;
10
+ color : # 383838 ;
11
+ min-height : 100vh ;
12
+ padding : 1em ;
13
+ box-sizing : border-box;
14
+ background-color : # e7e4e4 ;
15
+ display : flex;
16
+ flex-direction : column;
17
+ justify-content : center;
18
+ align-items : center;
19
+ max-width : 400px ;
20
+ margin : 0 auto;
21
+ }
22
+ .right {
23
+ font-size : .8rem ;
24
+ align-self : flex-end;
25
+ }
26
+ </ style >
27
+ </ head >
28
+ < body >
29
+ < p >
30
+ Type the secret code
31
+ </ p >
32
+ < p class ="right ">
33
+ it's pilila
34
+ </ p >
35
+ < script type ="text/javascript ">
36
+ const pressed = [ ] ;
37
+ const secretCode = 'pilila' ;
38
+
39
+ window . addEventListener ( 'keyup' , e => {
40
+ pressed . push ( e . key ) ;
41
+ pressed . splice ( - secretCode . length - 1 , pressed . length - secretCode . length ) ;
42
+ if ( pressed . join ( '' ) . includes ( secretCode ) ) {
43
+ alert ( 'Secret code found!' ) ;
44
+ }
45
+ } ) ;
46
+ </ script >
47
+ </ body >
48
+ </ html >
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ My goal is simply to learn the basics by doing many simple things rather than st
16
16
9 . [x] [ Dev Tools Domination] ( ./09-must-know-dev-tool-tips ) - [ Codepen] ( http://codepen.io/pouyio/pen/BQbbdp?editors=1111# )
17
17
10 . [x] [ Hold Shift and Check Checkboxes] ( ./10-hold-shift-and-check-checkboxes ) - [ Codepen] ( http://codepen.io/pouyio/full/RoOyqj/ )
18
18
11 . [x] [ Custom Video Player] ( ./11-custom-html5-video-player ) - [ Codepend] ( http://codepen.io/pouyio/full/bByVLB/ )
19
- 12 . [ ] Key Sequence Detection
19
+ 12 . [x] [ Key Sequence Detection] ( ) - [ Codepen ] ( http://codepen.io/pouyio/full/vywmwQ/ )
20
20
13 . [ ] Slide in on Scroll
21
21
14 . [ ] JavaScript References vs. Copying
22
22
15 . [ ] LocalStorage
You can’t perform that action at this time.
0 commit comments