There's an Easter egg on Facebook:
Login facebook.com, click anywhere on your homepage, keyboard input up, up, down, down, left, right, left, right, B, A, enter, click on the page or scroll through the scroll bar, you will find special changes (pictured below), Hey ^^
Played "The Soul Dou Luo" friend, certainly one eye can see the input character originally is "The Soul Dou Luo" in "The Secret". In fact, the term "secret" is called Konami Code, see illustration in detail:
So how do you add a similar egg to your own page with JavaScript?
Abhi provides a general idea in the article "Konami Code on Facebook:how to implement it on your site":
Copy Code code as follows:
var $ = {
Enabled:false,
Tmp:array (),
_konamicode:array (65,66,39,37,39,37,40,40,38,38),
Init:function () {
This.tmp = Array (65,66,39,37,39,37,40,40,38,38);
},
Konamicode:function (e) {
if (!this.enabled) {
var t = This.tmp.pop ();
if ((e.keycode-t) = = 0) {
if (This.tmp.length = = 0) {
This.enabled = true;
}
} else {
This.init ();
}
} else {
This.action ();
}
},
Change the action () function to whatever your want to
Action:function () {
Alert ("Konami Code activated");
}
}
However, the Abhi method is still redundant point, the Jarfalk in the message provided a short code:
Copy Code code as follows:
var k=[];
Function (e) {
K.push (E.keycode);
if (k.tostring (). IndexOf ("38,38,40,40,37,39,37,39,66,65") >=0) {
Alert ("Konami Code activated");
}