-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkonami.html
51 lines (42 loc) · 1.29 KB
/
konami.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Konami Code</title>
</head>
<body>
<h1>Konami Code</h1>
<p>Enter the Konami Code to get 30 more lives!</p>
<p class="hint">Didn't play video games as a kid?</p>
<p class="hide">The Konami Code: Up, Up, Down, Down, Left, Right, Left, Right, B, A ( ↑ ↑ ↓ ↓ ← → ← → B A )</p>
<script src="js/jquery-2.2.4.js"></script>
<script>
"use strict";
// hide and show code hint
$(document).ready(function() {
var hideText = $(".hide").html();
$('.hide').css("color", "white");
$(".hint").click(function () {
$(hideText).css("color", "black");
});
});
// set up array of correct keys
var codeKeys = [38,38,40,40,37,39,37,39,66,65,13];
var counter = 0;
// set up check to see if first key is correct
$(document).keyup(function(e){
console.log(e.keyCode);
if (codeKeys[counter] == e.keyCode) {
counter+=1;
} else {
counter=0;
alert("You have entered an incorrect sequence. Try again.");
};
if (counter == codeKeys.length){
counter=0;
alert("You have entered the correct sequence. You win 30 more lives!");
}
});
</script>
</body>
</html>