Skip to content

Instantly share code, notes, and snippets.

@velfundert
Created January 2, 2017 09:36
Show Gist options
  • Save velfundert/9c072e83b46e682c8779b7426dabb80e to your computer and use it in GitHub Desktop.
Save velfundert/9c072e83b46e682c8779b7426dabb80e to your computer and use it in GitHub Desktop.
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