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 kys = [],
chk = function (event) {
kys.push(event.keyCode);
if (kys.length > 11) {
kys.shift();
}
if (3.8384040373937394e+21 === 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