Created
March 30, 2017 22:54
-
-
Save AdamLantz/d145e27cc713eff79e9f7698db26aa39 to your computer and use it in GitHub Desktop.
Javascript file to listen for Konami code to be entered by keyboard
This file contains hidden or 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
/** | |
* Created by adamg on 3/29/2017. | |
*/ | |
(function(){ | |
var charSet = ["ArrowUp","ArrowUp","ArrowDown","ArrowDown","ArrowLeft","ArrowRight","ArrowLeft","ArrowRight","b","a"]; | |
var charInSet = 0; | |
document.addEventListener('keydown',function(e){ | |
if(e.key == charSet[charInSet]){ | |
console.log("Match for char: " + charSet[charInSet]); | |
charInSet++; | |
if(charInSet==charSet.length){ | |
console.log("secret triggered"); | |
} | |
} | |
else{ | |
charInSet = 0; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment