Konami-JS: Adding the Konami Code to your site

Apr 28

With the recent attention surrounding ESPN and their use of the Konami Code, I thought it would be fun to make a JavaScript library that allowed everyone to take advantage of this time-honored cheat code:

http://konami-js.googlecode.com

By adding just a few lines to your site, you can set it up so the Konami Code does…  Well, pretty much anything!  The default behavior is to load a new web page, but if you’re fluent in JavaScript, you can change the konami.code() method to do whatever you want.  Checkout some konami-js examples.

Try entering it now: Up, Up, Down, Down, Left, Right, Left, Right, B, A, Enter

{ 10 comments… read them below or add one }

1 Paul Irish Apr 28 at 11:32 am

Nice work!
FYI the espn site was using some code from here: http://paulirish.com/2009/cornify-easter-egg-with-jquery/

Maybe there are some ideas in there you can use.
This is certainly awesome though. More sites need something cool under their konami. :)

Cheers

Reply

2 George Mandis Apr 28 at 11:57 am

Thanks Paul. When I started making it originally I was going to use jQuery, but then I thought it would be cool if it didn’t have any dependencies. I didn’t look at the ESPN code at all, so it’s interesting to see where our solutions are similar and where they diverge. Your array approach probably makes more sense than my use of setTimeout(). The anal retentive person in me didn’t like the idea of continuously adding to a variable every time the user pressed a key, although I suppose it doesn’t much matter.

I’m thinking Konami needs to evolve into some sort of new interface standard, to the point where it’s strange when a site doesn’t make use of it… :)

Reply

3 Paul Irish Apr 28 at 2:36 pm

I’m thinking Konami needs to evolve into some sort of new interface standard, to the point where it’s strange when a site doesn’t make use of it

I could not agree more.

Reply

4 Cron May 7 at 7:34 pm

Nice! I hope you don’t mind if I start spreading the word. Obviously, all credit goes to you.

Reply

5 Bouke van der Bijl May 8 at 12:54 pm

Wow, super awesome work man!

This is also a good code base for making other “combos”

Reply

6 George Mandis May 8 at 1:10 pm

Yeah, you can do quite a bit more with it if you’re so inspired. You inspired me to update the code slightly just now. Instead of the Konami Code being hard-wired into the if statement it’s stored in konami.pattern. The default sets it to the Konami Code, but if you want to redefine it on the fly you can do that now, so long as you know the keyCodes.

Reply

7 Kevin Nov 17 at 8:31 pm

I am trying to set up something using Konami on my site. I have been able to get it to go to another page and whatnot, but can anybody help me get it to play an audio clip from an online source when the sequence is entered?

Reply

8 George Mandis Nov 17 at 8:33 pm

Hi Kevin,
You should check out:

http://www.schillmania.com/projects/soundmanager2/

You could easily setup the “konami” event to trigger a sound this way.

Reply

9 Joa Dec 17 at 11:36 am

I think you should change the condition to “konami.input.indexOf(“3838404037393739666513″)!=-1) “, because sometimes you mess up and try to do it again (:

Reply

10 George Mandis Dec 17 at 12:47 pm

@Joa – I think you’re right. The setTimeout() is kind of silly and I’m not sure what prompted me to do that.

I actually tweaked the code this morning to use that approach, as well as enable creating “multiple” easter eggs with different key combinations. Stay tuned!

Reply

Leave a Comment

Comments will be closed on Feb 15.

Previous post:

Next post:

Technorati Profile