Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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