The Mint Easter Egg and Making Your Own Javascript Easter Egg
You may have read or seen the "easter egg" that's in the Mint stats package that pops up a graphic when you enter the Konami Nintendo cheat code. I figured some people might like to know how to do their own in a similar fashion. It's only coded for IE, but you'd only have to adjust for the Mozilla event model instead or together. However, only using the one browser makes for a simpler explanation.
Below is the entirety of a demo of how to do this. The simplest way to use it to build your own is to save it to an HTML file, open it in IE. Type the series of keystrokes you'd like as your easter egg trigger and hit the "Reveal" button. The series of numbers you see are your numbers to put into $eastereggcode. What's in there now is "UP UP DOWN DOWN LEFT RIGHT LEFT RIGHT B A", using the arrow keys for the directions. This sample just does a window.alert(), but whatever effect you want would go in that spot if you'd like a more elaborate result.
Your deployed script doesn't need the reveal() function. Otherwise, you just need to put your snippet into the page and wait for people to discover. Or, leak the information like every other good easter egg and enjoy.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="JavaScript">
<!--
var $keystrokes = "";
var $eastereggcode = "38 38 40 40 37 39 37 39 66 65";
function log_keystrokes($event){
//ie only
$keycode = $event.keyCode;
$keystrokes = $keystrokes + $keycode + " ";
$match = $keystrokes.indexOf($eastereggcode);
if($match > -1){
window.alert("easter egg");
$keystrokes = "";
}
}
function reveal(){
document.write($keystrokes);
}
//-->
</script>
</head>
<body onkeydown="log_keystrokes(event);">
<button onclick="reveal();">Reveal</button>
</body>
</html>

November 3rd, 2005 at 9:38 am
Hmm I may have to try this when I put up my new page…
March 18th, 2006 at 10:33 pm
Man, thanks for the code, it gived me some cool ideas for the credits of the websites i code!