Last active
August 29, 2015 14:09
-
-
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.
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
// 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