Skip to content

Instantly share code, notes, and snippets.

@alassek
Created April 28, 2011 07:39
Show Gist options
  • Select an option

  • Save alassek/945968 to your computer and use it in GitHub Desktop.

Select an option

Save alassek/945968 to your computer and use it in GitHub Desktop.
konami code for jQuery
(function ($) {
$.fn.konami = function (callback, code) {
code = code || "38,38,40,40,37,39,37,39,66,65,13";
return this.each(function () {
var kkeys = [];
$(this).keydown(function (e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(code) >= 0) {
$(this).unbind('keydown', arguments.callee);
callback(e);
}
}, true);
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment