-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
35 lines (29 loc) · 857 Bytes
/
konami.html
File metadata and controls
35 lines (29 loc) · 857 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
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
</head>
<body>
<h1>Konami Code</h1>
<script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
<script>
"use strict";
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13];
var user = [];
var counter = 0;
$(document).keyup(function(event){
console.log(event.keyCode);
user.push(event.keyCode);
if(konami[counter] !== user[counter] ){ //if the user input is incorrect
alert("not correct konami code!");
}
else if(konami[konami.length-1] === user[konami.length-1]){
alert("correct konami code - you get 30 lives!");
}
else{
counter++;
}
});
</script>
</body>
</html>