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>