Created
August 8, 2017 19:46
-
-
Save petvas/5fc7df7128e0429da34116d195e57270 to your computer and use it in GitHub Desktop.
Simple Detector
This file contains 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 onKonamiCode(cb) { | |
var input = ''; | |
var key = '38384040373937396665'; | |
document.addEventListener('keydown', function (e) { | |
input += ("" + e.keyCode); | |
console.log(input, key.indexOf(input)); | |
if (input === key) { | |
return cb(); | |
} | |
if (!key.indexOf(input)) return; | |
input = ("" + e.keyCode); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment