Konami-JS

A dedicated site for Konami-JS is coming soon! It will feature more in-depth examples, compatability details, a better-maintained list of sites that are using Konami-JS and even a forum! Follow @konamijs on Twitter to find out when it goes live!

Every site should have the Konami Code. It makes things more fun. If you're unfamiliar with it, the Konami Code is a cheat code that appeared in many of Konami's video games going all the way back to 1986. Recently, ESPN received attention for the funny, flashy things that would happen when the code was entered on their website. Those shenanigans were the inspiration for whipping up this script.

The Code

In case you don't know, the Konami Code is:

Up, Up, Down, Down, Left, Right, Left, Right, B, A, Start

For our purposes, we've replaced Start with Enter.

The JavaScript Code

The code is being hosted over at Google Code where you can download the examples and original source:

http://code.google.com/p/konami-js/

The beauty of hosting it there is you can just copy and paste the examples below. No need to download anything.

Simplest Example

The most basic example takes the user to Google when they enter the code correctly. Just add this in the <HEAD></HEAD>:

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

The default behavior is to redirect the browser to whatever web address is passed to konami.load()

Second Simplest Example

A slightly more complicated examples show how you can redefine konami.code() and have it alert with a pop-up message instead:

<script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
	konami = new Konami()
	konami.code = function() {
		alert("You have entered the KONAMI CODE!  You now have 30 lives.  Kinda.")
		}

	konami.load()
</script>
			

When the user enters the Konami Code on this page, he or she is greeted with a message informing them that they've just acquired 30 lives. Sort of. Redfining konami.code() opens the door to do some fun things. You could even hook it into your Google Analytics tracking and measure when your users enter the code, for whatever that's worth.

Third Simplest Example

Maybe you want some other combination of keys to trigger a special event on your page? No problem. Just redefine the konami.pattern variable to match the sequence of keyCodes you want. This example would match the user hitting up twelve times:

<script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
	konami = new Konami()
	konami.pattern = "383838383838383838383838"
	konami.code = function() {
		alert("You have hit up four times.  Why you did this, I don't know.")
		}

	konami.load()
</script>
						

WordPress Plugin

Adrian Hanft has developed a WordPress plugin called Konami Easter Egg that uses Konami-JS to embed the Konami code in your blog

iPhone Support!

Konami-JS now features iPhone gesture support! You don't have to do anything differently either - konami.load() will automatically call konami.iphone.load() and pass the same variables along to it, triggering the same easter egg. If you'd like the Konami Code to trigger something different for iPhone users, you can do this:

<script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
	konami = new Konami()
	konami.iphone.code = function() {
		alert("You have entered the Konami Code on your iPhone.  Nice work.")
		}

	konami.load()
	
</script>
											

It should be noted that "A, B, Start" has been replaced with three taps on the screen.


I wonder what would happen if you entered the Konami Code right now?


Find this silly script useful? Feeling charitable? Want to buy me coffee? Or maybe just a phone call on a public phone booth? Why not donate!

I've actually maintained and upgraded Konami-JS, perfecting iPhone support, changing the code to accomodate multiple easter-eggs on a single page, and other user-requests that have rolled in. If you want to throw a buck my way, it would be appreciated.

George Mandis is web programmer and designer from Portland, OR. He is genuinely amused that this page has been gettings thousands of hits for "Konami Code" and is also genuinely flattered and slightly perplexed to find people actually using it.


KONAMI CODE!!!



+30 LIVES!