Konami Code jQuery Plugin: Pointlessly Easy

Everything old is new again. The Konami Code is the most famous video game cheat of all time. It began in 1986 with the original Nintendo system -- almost every game that the Konami company produced contained the code. Eventually even games that were produced by other companies included the code.
Well in 2009 the code has seen a resurgence. ESPN, Facebook, and even Google Reader have all added Easter Eggs that are triggered by the Konami Code. A more comprehensive listing of the sites that have enabled the code is at konamicodesites.com. (Of course you must enter the code to see them!)
So if you want your site to get in on the retro action, we've put together a little jQuery plugin that makes it dead simple.
The Konami Code Plugin
To enable the code on your site, you just need to make a simple call and pass in the function you want executed.
$(window).konami(function(){ alert('Konami Code Activated!')});
The only advanced option available is the ability to switch from the default code to one of your choosing. Just pass in a comma-separated string of ASCII codes and it will run when they have been pressed. The following code would trigger when "n,m,c" is typed.
$(window).konami(function(){ alert('NMC Code Activated!')}, "78,77,67");
To see an example in action check out the demo.
You can also download a zip of the demo with the plugin.
Have fun and be sure to leave a link to your site with the code in the comments.
Update: The code in the zip file is now corrected as described in the comments.
Update 2 (8/2/2011): Philip's update from the comment to limit memory usage has been added.

Comments
David Bootle
There is a (deliberate?) error in the konami.js file in the .zip download.
Check the ASCII code list... the last one should be 65 (for A) - not 66 (B).
Adam
Your demo doesn't work with IE8. If you bind the event handler to the document, then it will work.
zobzz
yeah Adam, the demo doen't work, because there's a little problem about the key codes in the JS file
replace this :
38,38,40,40,37,39,37,39,66,66
by this :
38,38,40,40,37,39,37,39,66,65
vaisselle porcelaine
other than that thanks a lot for the nifty little function ^^
Joel Sutherland
The code is now updated to work by default.
Mik
Would that be a problem if that was used on a game site where you could expect a lot of key presses over a long period of time?
Jimmy Gunawan
Works on Chrome, Firefox.
jay
This is because the konami.js is using the wrong function signature for keydown.
Simply remove "true" as the second argument in the konami.js source on line 14, and this should fix it.
James Morrish
Júlio Santos
:D
Philip Peterson
while (kkeys.length > code.split(',').length) {
kkeys.shift();
}
Rob
Ryan
Chris
}, true);
});
}
})(jQuery);
Change it to:
});
});
}
})(jQuery);
et voila.
Leave a Comment