Skip to content

Instantly share code, notes, and snippets.

@lyonsinbeta
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyonsinbeta/42e74d930b02a132ff25 to your computer and use it in GitHub Desktop.
Save lyonsinbeta/42e74d930b02a132ff25 to your computer and use it in GitHub Desktop.
CU Online Easter Eggs
var beetlejuice = "6669698476697485736769";
var konami = "38384040373937396665";
var input = "";
var timer;
//The following function sets a timer that checks for user input. You can change the variation in how long the user has to input by changing the number in ‘setTimeout.’ In this case, it’s set for 500 milliseconds or ½ second.
window.addEventListener("keyup", function(e) {
input += e.which;
clearTimeout(timer);
timer = setTimeout(function() { input = ""; }, 500);
check_input();
}, false);
//Once the time is up, this function is run to see if the user’s input is the same as the secret code
function check_input() {
switch (input) {
case beetlejuice:
var audio = new Audio('beetlejuice.mp3');
audio.play();
break;
case konami:
alert("Straight A's unlocked!");
break;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment