Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Last active September 2, 2015 12:45
Show Gist options
  • Save greyaperez/7b6c19bb421ae7fccae9 to your computer and use it in GitHub Desktop.
Save greyaperez/7b6c19bb421ae7fccae9 to your computer and use it in GitHub Desktop.
Konami Code
function konamiCode () {
var keys = [];
var valid = _.map("38384040373937396665".match(/.{1,2}/g), _.parseInt);
document.onkeydown = function (key) {
if (key > 10) {
document.onkeydown = null;
return;
}
keys.push(key.which);
if (keys.length == 10 && JSON.stringify(keys) === JSON.stringify(valid)) {
// Code Success, do something...
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment