Konami Code


The Konami code… if you were born in 1990 or earlier, and play (or played) video games, you probably already know what I’m talking about.

The history of the Konami code is awesome in it’s own rite. Here’s the short version: the Konami code is a famous cheat code (up, up, down, down, left, right, left, right, B, A) that first appeared in NES games like Contra. Many times the code was added to video games as a tribute to the classic games or as a tribute to Kazuhisa Hashimoto, the developer who accidentally left the cheat code in the game when it was sold to the public.

That homage has been proliferated by nerds and techies through many games and, eventually, made it’s way on websites.

YES, THERE IS A CHEAT CODE FOR THE INTERNET.

Sort of. It usually just reveals an easter egg on that site. You can find a whole list of websites that use Konami codes at Konami Code Sites. It’s a lot of fun finding the secret content people have put behind respectable websites.

Some of you are probably thinking “But how do I put a Konami code on MY site?!?!” Well, at least that’s what I was wondering.

There is a pretty robust Konami code javascript library that’s even iPhone compatible, hosted at Google Code (on an iPhone, it’s swiping and tapping, so it’s “up, up, down, down, left, right, left, right, tap, tap, tap”.

For those who are looking for the quickest and easiest version, I found this over at snaptortoise.com:


<script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script><script type="text/javascript">// <![CDATA[
konami = new Konami()
konami.load("http://www.google.com");
// ]]></script>

But that… is almost too easy. And you may want to do more custom things than just loading a different page. Or maybe you want to do a slightly different cheat code. I found some simpler, flexible (albeit not as flashy) javascript code on another blog:


// check to make sure that the browser can handle window.addEventListener
if (window.addEventListener) {
// create the keys and konami variables
var keys = [],
konami = "38,38,40,40,37,39,37,39,66,65";

// bind the keydown event to the Konami function
window.addEventListener("keydown", function(e){
// push the keycode to the 'keys' array
keys.push(e.keyCode);

// and check to see if the user has entered the Konami code
if (keys.toString().indexOf(konami) >= 0) {
// do something such as:
// alert('Konami');

// and finally clean up the keys array
keys = [];
};
}, true);
};

The “38,38,40,40,37…” are keypress IDs, so you would change this portion if you wanted a different cheat code.

There’s even a WordPress plugin for Konami codes!

Hope this was helpful, and enjoy the easter egg hunt!

Advertisements
  1. tj
    November 16, 2012 at 08:49

    Why isn’t it enabled on this page???

    • November 16, 2012 at 12:37

      Justom Javascript is disabled on sites hosted at wordpress.com! I plan to put a Konami code on my other site, and I’ll post another article about it when I do.

  2. tj
    December 26, 2012 at 23:08
    • January 4, 2013 at 09:15

      This is awesome! I came across this on a site somewhere and figured it was totally custom. Now that I know it’s in a convenient package, I’m going to be dropping this into all of my sites 🙂

  1. No trackbacks yet.

Care to share your two cents?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: