Skip to content

Instantly share code, notes, and snippets.

@carolusquintus
Last active August 29, 2015 14:09
Show Gist options
  • Save carolusquintus/73dea21dff0cd04c3033 to your computer and use it in GitHub Desktop.
Save carolusquintus/73dea21dff0cd04c3033 to your computer and use it in GitHub Desktop.
Konami Code implementation for Dojo Framework. Eventually it will change to be more general.
// KONAMI CODE: ↑ ↑ ↓ ↓ ← → ← → B A
var konamiCode = [38, 38, 40, 40, 37, 39, 37, 39, 98, 97];
var index = 0;
window.onkeypress = function(e) {
var keyPressed = (e.charCode != 0 ? e.charCode : e.keyCode);
if (keyPressed == konamiCode[index]) {
index++;
if (index == konamiCode.length) {
console.log("OK Konami Code");
index = 0;
}
} else {
console.log("Restart Konami Code");
index = 0;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment