-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (31 loc) · 955 Bytes
/
index.js
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
// https://www.myinstants.com/media/sounds/turn-down-for-what.mp3
function Konami(callback) {
const pattern = "38384040373937396665";
let input = "";
let _keydownHandler = (e) => {
input += e.keyCode;
if (input.length > pattern.length) {
input = input.substr((input.length - pattern.length));
}
if (input === pattern) {
callback();
input = '';
e.preventDefault();
return false;
}
};
document.addEventListener("keydown", _keydownHandler, false);
};
let playTurnDownForWhat = () => {
let audio = document.getElementById('turnDownForWhat');
if (!audio) {
let body = document.getElementsByTagName('body')[0];
audio = document.createElement('audio');
audio.volume = 1;
audio.id = 'turnDownForWhat';
audio.setAttribute('src', 'https://www.myinstants.com/media/sounds/turn-down-for-what.mp3');
body.append(audio);
}
audio.play();
}
Konami(playTurnDownForWhat);