Skip to content

Instantly share code, notes, and snippets.

@lakenen
Last active August 29, 2015 13:56
Show Gist options
  • Save lakenen/8815852 to your computer and use it in GitHub Desktop.
Save lakenen/8815852 to your computer and use it in GitHub Desktop.
Discreet Konami Code
function dkc(fn) {
var k1 = 28978765259,
k2 = 132455748307,
kys = [],
chk = function (event) {
kys.push(event.keyCode);
if (kys.length > 11) {
kys.shift();
}
if (k1 *k2 === parseInt(kys.join(''), 10)) {
fn();
}
};
window.addEventListener('keydown', chk);
return {
stop: function () { window.removeEventListener('keydown', chk); }
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment