Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Letter konami-code [jQuery Plugin]

View jquery.konami.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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.