Skip to content

Instantly share code, notes, and snippets.

@amiel
Created July 20, 2010 19:59
Show Gist options
  • Save amiel/483472 to your computer and use it in GitHub Desktop.
Save amiel/483472 to your computer and use it in GitHub Desktop.
$.konami = (function() {
var cheatPos = 0,
konami_event = 'konami',
konami = function(fn) {
$(window).bind(konami_event, fn);
};
konami.cheat = [38,38,40,40,37,39,37,39,66,65];
$(document).bind('keydown',function(e) {
if (e.keyCode == konami.cheat[cheatPos]) ++cheatPos; else cheatPos = 0;
if (cheatPos == konami.cheat.length) $.event.trigger(konami_event);
});
return konami;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment