Last active
September 2, 2015 12:45
-
-
Save greyaperez/7b6c19bb421ae7fccae9 to your computer and use it in GitHub Desktop.
Konami Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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