Skip to content
A simple javascript library to add easter eggs to web pages.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Add .editorconfig file Apr 23, 2015
.gitignore Added ability to pass characters instead of keyCodes. Reworked Listen Apr 16, 2015
Gruntfile.js Added explicit LICENSE file. Apr 22, 2015 Updated README with CDN URL. May 14, 2019
bower.json Added myself in to the bower config Apr 21, 2015
egg.js Update egg.js Mar 1, 2017
egg.min.js Update egg.min.js Mar 1, 2017
package.json Updated to MIT license in package.json, added MIT license to egg.js Apr 22, 2015



Egg.js is a simple JS library that has no prerequisites and allows you to easily add web easter eggs by watching the user's key strokes.


It's really easy to use. Just include the egg.js file on the page...

<script type="text/javascript" src=""></script>

(Thanks to Cloudflare for hosting the library!)

...then use the addCode() function to add in your easter eggs. You need to pass it the character sequence to trigger the easter egg callback (which can either be in plain English or Javascript key codes), a function to trigger when it happens, and an optional set of metadata. Metadata can be anything from a string to an object.

var egg = new Egg();
  .addCode("up,up,down,down,left,right,left,right,b,a", function() {
    jQuery('#egggif').fadeIn(500, function() {
      window.setTimeout(function() { jQuery('#egggif').hide(); }, 5000);
    }, "konami-code");
    console.log("Hook called for: " + this.activeEgg.keys);

You can also define the easter egg using the constructor:

var egg = new Egg("up,up,down,down,left,right,left,right,b,a", function() {
  jQuery('#egggif').fadeIn(500, function() {
    window.setTimeout(function() { jQuery('#egggif').hide(); }, 5000);
  }, "konami-code");

You can also add a hook, as shown above using addHook(), that will run after any egg code is triggered. You could use it to fire a Google Analytics event or send out a tweet that someone finally found your easter egg. Hooks get access to the whole Egg.js object so you can pull information about the easter egg that fired via this.activeEgg

You can see a live example of this on egg.js website.


I put an easter egg in pretty much everything I make and after copying the same basic code over and over again I figured I should make it in to a simple library for my own use.


Created by Mike Flynn / @thatmikeflynn and Rob McVey / @negative_sleep

You can’t perform that action at this time.