Skip to content

Instantly share code, notes, and snippets.

@chrismealy
Created February 21, 2012 18:10
Show Gist options
  • Save chrismealy/1877900 to your computer and use it in GitHub Desktop.
Save chrismealy/1877900 to your computer and use it in GitHub Desktop.
easter egg
$(document).ready(function() {
var easterEgg = 'egg';
var eggLength = easterEgg.length;
var keyHistory = '';
var match;
$(document).keypress(function(e) {
keyHistory += String.fromCharCode(e.which)
match = keyHistory.match(easterEgg);
if(match) {
alert(match);
keyHistory = match = '';
} else if (keyHistory.length > 30) {
keyHistory = keyHistory.substr((keyHistory.length - eggLength - 1));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment