In both cases, it does not matter, nobody is perfect, but what we should know is that some truly affectionate developer though to put this code to enable secret user powers, even if the the software is, as example, extremely recent.
So why not? Why can't we all have our secret mode in the most popular platform as the World Wide Web is?
Konami Code Event
var onkonamicode = function(el, fn){
// The Super Code Event by WebReflection - Mit Style
function onkonamicode(e){
konamicode.push((e || event).keyCode || e.charCode);
if(
konamicode.length === 10 &&
konamicode.join(".") === "38.38.40.40.37.39.37.39.66.65"
){
if(el.removeEventListener)
el.removeEventListener("keydown", onkonamicode, false);
else
el.detachEvent("onkeydown", onkonamicode);
fn(e);
};
clearTimeout(i);
i = setTimeout(clear, 1000);
};
function clear(){
konamicode = [];
};
var konamicode = [], i = 0;
if(el.addEventListener)
el.addEventListener("keydown", onkonamicode, false);
else
el.attachEvent("onkeydown", onkonamicode);
};
How To Activate Konami Code
It is that simple:
onkonamicode(document, function(e){
alert("access guaranteed");
});
Now try to perform the magic sequence and that's it, you have extra power!
Did you add the code to this blog post?
ReplyDeleteAlso, it would be nice if at the 10th character konamicode could be reset if it's not correct.
But I like it!
Alejandro of course I added the code, why?
ReplyDeleteMy implementation goes a bit farther than your suggestion, as soon as you stop typing it resets the array (the 1 second timeout)
In few words i you start and before 10 chars you type something wrong, you wait "a bit" and you can type again.
There is no need for a length based reset, also because the user cannot know if he is in the middle of that length or at the beginning so every moment is fine to type it ;)
http://james.padolsey.com/javascript/konami-craziness/
ReplyDelete