-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
36 lines (28 loc) · 1021 Bytes
/
konami.html
File metadata and controls
36 lines (28 loc) · 1021 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
</head>
<body>
<h1>Konami Code</h1>
<script>
"use strict";
document.addEventListener("keyup", event => console.log(event.key) );
let keySequence = [];
document.addEventListener('keydown', function(event) {
keySequence.push(event.key);
if (keySequence.join('') === 'ArrowUp,ArrowUp,ArrowDown,ArrowDown,ArrowLeft,ArrowRight,ArrowLeft,ArrowRight,KeyB,KeyA,Enter') {
alert("You did it!");
keySequence = []; // Reset the key sequence
}
});
</script>
</body>
</html>
<!--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!-->