Monday, August 17, 2009

Konami Code as DOM Event

If You do not know what is the Konami Code you are too young, or not geek at all.
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);
konamicode.length === 10 &&
konamicode.join(".") === ""
el.removeEventListener("keydown", onkonamicode, false);
el.detachEvent("onkeydown", onkonamicode);
i = setTimeout(clear, 1000);
function clear(){
konamicode = [];
var konamicode = [], i = 0;
el.addEventListener("keydown", onkonamicode, false);
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!

No comments:

Post a Comment