-
Notifications
You must be signed in to change notification settings - Fork 0
/
konami.html
49 lines (40 loc) · 1.17 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
<!DOCTYPE html>
<html>
<head>
<title>Konami Code</title>
<link rel="stylesheet" href="css/konami.css">
</head>
<body>
<h1>Konami Code</h1>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"
integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script>
<script src="js/jquery.js"></script>
<script>
"use strict";
// $(document).keyup(function (event) {
// console.log(event.keyCode);
let pattern = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a'];
let current = 0;
$(document).keyup(function (e) {
console.log(e.key)
if (pattern.indexOf(e.key) < 0 || e.key !== pattern[current]) {
current = 0;
console.log(current);
return;
} else {
current++;
console.log(current);
}
if ((pattern.length) === current) {
console.log('success')
$('body').css('background-image', "url('img/contra-logo2.png')");
$('body').css('background-color','black');
$('h1').css('display','none');
let audio = new Audio('audio/Konami Logo.mp3');
audio.play();
}
});
// If the key isn't in the pattern, reset
</script>
</body>
</html>