Thursday, 25 June 2009 17:51

There's a really cool site at konamicodesites.com that lists a whole bunch of sites that have easter eggs if you type a certain pattern while visiting. That pattern is the famous Konami Code. It lists some pretty large sites, like Facebook and Digg.

I went ahead and wrote a quick little bit of JavaScript that implements this functionality. It's loaded into the site you're looking at right now!

Here's the source code to make this work, released as Kopyleft (so do whatever you want with it) GNU/GPL, to begrudgingly comply with the rules of extensions.joomla.org.

var kcode = [38,38,40,40,37,39,37,39,66,65,13];
var kc_ptr = 0;
function konami( e )
{
  // make sure IE sees event
  e = e||window.event;
  // keyCode
  var kc = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
  // reset pointer if keycode isn't the next in sequence
  if( kc != kcode[kc_ptr] )
  {
    kc_ptr = 0;
    return;
  }
  // reset pointer & execute code
  if( ++kc_ptr == kcode.length )
  {
    kc_ptr = 0;
    // code to execute
    // replace the next line with the action you want to take
    console.log( 'konami' );
  }
}
window.addEvent( 'load', function( e )
{
    document.onkeydown = konami;
});
Last Updated on Monday, 07 December 2009 04:53
 

Add your comment

Your name:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries. Jeff Channell is not affiliated with or endorsed by Open Source Matters or the Joomla!® Project.

Santorum
Joomla Extensions