Skip to content

Commit b77e284

Browse files
committed
day 12
1 parent 1910fe6 commit b77e284

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

12-key-sequence-detection/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Key sequence detection
2+
Watch this challenge live in [codepen](http://codepen.io/pouyio/full/vywmwQ/).

12-key-sequence-detection/index.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ My goal is simply to learn the basics by doing many simple things rather than st
1616
9. [x] [Dev Tools Domination](./09-must-know-dev-tool-tips) - [Codepen](http://codepen.io/pouyio/pen/BQbbdp?editors=1111#)
1717
10. [x] [Hold Shift and Check Checkboxes](./10-hold-shift-and-check-checkboxes) - [Codepen](http://codepen.io/pouyio/full/RoOyqj/)
1818
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/)
2020
13. [ ] Slide in on Scroll
2121
14. [ ] JavaScript References vs. Copying
2222
15. [ ] LocalStorage

0 commit comments

Comments
 (0)