-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
85 lines (67 loc) · 2.82 KB
/
konami.html
File metadata and controls
85 lines (67 loc) · 2.82 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
<style>
.spin { animation: spin 3s linear infinite; }
.goPackers {
color: white;
text-transform: uppercase;
}
</style>
</head>
<body>
<div class="spin">
<h1 class="spin">Konami Code
<span class="goPackers">
<br>
go packers!!!
</span>
</h1>
</div>
<!--<script>-->
<!-- "use strict";-->
<!-- document.addEventListener("keyup", event => console.log(event.key) );-->
<!--</script>-->
<script>
"use strict";
document.addEventListener("keyup", event => console.log(event.key) );
const konamiCode = ["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown", "ArrowLeft", "ArrowRight", "ArrowLeft", "ArrowRight", "b", "a", "Enter"];
let konamiCodeIndex = 0;
document.addEventListener("keyup", event => {
const key = event.key;
if (key === konamiCode[konamiCodeIndex]) {
konamiCodeIndex++;
if (konamiCodeIndex === konamiCode.length) {
document.body.style.backgroundColor = "green";
document.body.style.color = "yellow";
alert("You have added 30 lives!");
konamiCodeIndex = 0;
}
} else {
konamiCodeIndex = 0;
}
});
</script>
<!-- // Here's an example of how the event listener captures arrow key events:-->
<!-- //-->
<!-- // javascript-->
<!-- // Copy code-->
<!-- // document.addEventListener("keyup", event => {-->
<!-- // const key = event.key; // This will be "ArrowUp" or "ArrowLeft" for arrow keys-->
<!-- // // Rest of the code-->
<!-- // console.log(key);-->
<!-- // });-->
</body>
</html>
<!--The Konami Code was a cheat code that appeared on a number of games from Konami. Contra was one of the early NES games to have featured the Konami Code. Contra would start you with 3 lives per game, but after the start screen, if you entered the Konami Code, you would get 30 lives!-->
<!--The Konami Code: Up, Up, Down, Down, Left, Right, Left, Right, B, A ( ↑ ↑ ↓ ↓ ← → ← → B A )-->
<!--Create a file named konami.html using the template below. This code will log a number reference that is tied to each key that is entered on your keyboard. Open the console and view the output as you type on the keyboard.-->
<!--Allow the user to enter the Konami Code: "↑ ↑ ↓ ↓ ← → ← → b a enter" (the return key)-->
<!--Find the matching sequence using the code above for each key in the Konami Code.-->
<!--Don't worry about capital a or b just check for lowercase.-->
<!--After the correct Konami Code sequence is inputted, have the script alert the user: "You have added 30 lives! Other ideas:-->
<!--Change the background screen.-->
<!--Play a sound.-->
<!--Be creative!-->
<!--Happy Playing.-->