Skip to content

Instantly share code, notes, and snippets.

@ljharb
Created July 31, 2013 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ljharb/6126127 to your computer and use it in GitHub Desktop.
Save ljharb/6126127 to your computer and use it in GitHub Desktop.
Konami code implementation
(function ($) {
var keys = [], code = '38,38,40,40,37,39,37,39,66,65';
var konami = function (e) {
keys.push(e.which);
if (keys.length >= 11 && keys.slice(-11).toString() !== code) {
keys = [];
/* do your konami thing here */
} else if (keys.length > 11) {
keys.length = 11;
}
};
$(document).on('keydown', konami);
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment