Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Letter konami-code [jQuery Plugin]
jQuery.konami = function(fn, code) {
// ↑ ↑ ↓ ↓ ← → ← → B A
code = code || [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
var i = 0;
$(document).keydown(function(e) {
var char = typeof code === 'string' ? String.fromCharCode(e.which).toLowerCase() : e.which;
i = char === code[i] ? i + 1 : 0;
if (i === code.length) {
fn();
i = 0;
}
});
};
$.konami(function() {
alert('Woohoo!');
});
$.konami(function() {
alert('Woohoo!');
}, 'foo');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.