-
Notifications
You must be signed in to change notification settings - Fork 0
/
kocode.js
43 lines (40 loc) · 1.32 KB
/
kocode.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
37
38
39
40
41
42
43
/* Copyright (C) 2019 Thanasis Vergoulis
*
* This code is a free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Contact email: vergoulis@athenarc.gr
*/
var pressed_keys = new Array(); //The last pressed keys.
var konami_keys = new Array(38,38,40,40,37,39,37,39,66,65); //The keys of konami code.
var cur_key_indicator = 0; //An indicator pointing to the current key.
/**
* Listening for ... the konami code!! :-)
*/
function konami_code(e)
{
var KeyID = (window.event) ? event.keyCode : e.keyCode;
if( KeyID == konami_keys[cur_key_indicator] )
{
cur_key_indicator = cur_key_indicator+1;
}
else
{
cur_key_indicator = 0;
}
if( cur_key_indicator == 10)
{
//PLACE YOUR PAGE-SPECIFIC CODE HERE! a simple example follows
alert("Easter egg!");
}
}