Created
January 2, 2017 09:36
-
-
Save velfundert/9c072e83b46e682c8779b7426dabb80e to your computer and use it in GitHub Desktop.
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
var executeOnKonami = function(callback, code) { | |
var codekeys = []; | |
var codestr; | |
if (code === null) { | |
codestr = '38,38,40,40,37,39,37,39'; | |
} else { | |
codestr = code.toString(); | |
} | |
return function(e) { | |
codekeys.push(e.keyCode); | |
if (codekeys.toString().indexOf(codestr) >= 0) { | |
callback(); | |
codekeys = []; | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment