-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonami.html
More file actions
48 lines (36 loc) · 998 Bytes
/
konami.html
File metadata and controls
48 lines (36 loc) · 998 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
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
</head>
<body>
<h1>Konami Code</h1>
<audio class="hidden" id="sound-effect">
<source src="audio/sonic_ring.mp3">
</audio>
<script src="js/jquery-3.5.1.min.js"></script>
<script>
"use strict";
var konamiCode = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13];
var enteredKeys = [];
var codeSound = document.querySelector('#sound-effect')
function keyChecker() {
for (var i = 0; i < enteredKeys.length; i++) {
if (enteredKeys[i] !== konamiCode[i]) {
enteredKeys = [];
return;
}
}
if (enteredKeys.length === 11) {
enteredKeys = [];
codeSound.play();
alert("Konami Code entered! +100 Continues!");
}
}
$(document).keyup(function(event){
enteredKeys.push(event.keyCode);
keyChecker();
});
</script>
</body>
</html>