-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
56 lines (49 loc) · 1.3 KB
/
konami.html
File metadata and controls
56 lines (49 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>konami code</title>
<!--Use and empty array to hold the users inputs using .push method -->
</head>
<body>
<!--text box -->
<div id="Enter">
<p>Enter a code to see what you win</p>
<input type="text" Code="" id="Konami">
</div>
<style>
#Enter{
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
border: solid 3px black;
height: 150px;
}
#Konami{
color: #FFFFFF;
}
</style>
<script>
"use strict";
document.addEventListener("keyup", event => console.log(event.key));
let userCode=[]
let konamiCode= ['ArrowUp','ArrowUp','ArrowDown','ArrowDown','ArrowLeft','ArrowRight','ArrowLeft','ArrowRight','b','a',`Enter`]
let userAttempt= 0;
document.querySelector('#Konami').addEventListener('keydown', function (event) {
userCode.push(event.key);
userCode= userCode.slice(-konamiCode.length);
if (userCode.length === konamiCode.length){
console.log('you win')
userAttempt=0;
} else {
userAttempt++
(userCode.length !== konamiCode.length);{
console.log('no fun for u')
}
if (userAttempt=11)
} });
</script>
</body>
</html>