Does Your Site Have The Konami Code?

Share this article


In my defense I’ve just returned from a two-week, mostly offline, holiday overseas. So I had no idea what he meant when my mate, Royce, sent me a direct tweet:

Why don’t you have a konami code on yer site?

Now, at this point I had the opportunity to quickly use Google to maintain the fragile charade that I’m hip to all the latest memes. But no, afflicted with sudden-onset honesty, I sent the less-than-stellar reply:

What’s a Konami Code?

I should have used the Google; my geek cred is in ruins. If there are any readers who have yet to hear of the Konami Code, then this issue will save you from the same fate.

I love easter eggs on web sites; I have a perverse attraction to spending the time and effort to write code for utterly pointless reasons. The Konami Code hails back to old-school console-gaming cheat codes; the key combo is up, up, down, down, left, right, left, right, B, A. If you’d like to know more, a video on Youtube explains everything. There’s been a rash of sites that have implemented an easter egg, triggered when you enter the code. The ESPN site did it for April Fools’ Day and the jQuery site has had a great one for ages, as well as Google Reader and even Facebook. Visit Konami Code Sites to find a list of sites.

I had a look around at several JavaScript-based solutions for implementing such an easter egg, and found a very slick jQuery example by Paul Irish that exhibits a little bit of JavaScript-fu. The script uses an event listener to intercept keydown events and keep track of all the keys entered. If the combination of keys pressed contains the Konami Code then the easter egg is triggered:

var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
  kkeys.push( e.keyCode );
  if ( kkeys.toString().indexOf( konami ) >= 0 ){
    // Launch easter egg here          

The script begins by declaring a couple of variables; kkeys, an empty array used to store the user’s key presses; and konami, a string representing the keycodes for the correct key combination.

An event listener is attached to the document object to listen for the keydown event. Every time a key is pressed while the page is loaded, the keycode is added to the kkey array. The script then checks to see if the Konami Code has been entered. If it has, then the event listener is removed and the easter egg is revealed.

Notice the use of arguments.callee? (I wrote about the strange but useful arguments object in Tech Times issue #215.) The callee property refers to the current function, so using arguments.callee is a great way for an event listener function to remove itself. In this example it also enables the event listener function to remain anonymous.

The easter egg on the Paul Irish site uses the services of Cornify, a highly useful unicorn and rainbow web service:

$.getScript('', function(){

There are a few other noteworthy examples I’ve found. Matt Snider has one using YUI where the script creates a custom event, and two other plain old JavaScript examples. The first is konami-js that uses timeouts to reset the Konami Code detection routine if there’s a long delay between key presses. The second is the onKonamiCode event handler by James Padolsey.

So what are you waiting for? You have the code; add the Konami Code to your site today.

Frequently Asked Questions (FAQs) about the Konami Code

What is the Konami Code?

The Konami Code is a sequence of button presses on a controller that was first used as a cheat code in Konami video games. The code is Up, Up, Down, Down, Left, Right, Left, Right, B, A. It was first used in the game Gradius for the Nintendo Entertainment System and has since been used in many other games, both by Konami and other companies.

Who created the Konami Code?

The Konami Code was created by Kazuhisa Hashimoto, a developer at Konami. He created the code as a way to make the game Gradius easier for him to play during testing. The code was left in the game when it was released, and players discovered it, leading to its widespread use and popularity.

How do I use the Konami Code?

To use the Konami Code, you need to press the buttons in the correct sequence. This is usually done on the title screen of the game, before you start playing. The sequence is Up, Up, Down, Down, Left, Right, Left, Right, B, A. In some games, you may need to press the Start button after entering the code.

What does the Konami Code do?

The effect of the Konami Code varies depending on the game. In the original Gradius, it gave the player a full set of power-ups. In other games, it might give extra lives, unlock secret levels, or have other effects. Some games even have negative effects if you enter the code.

Can I use the Konami Code in non-Konami games?

Yes, many non-Konami games have included the Konami Code as an Easter egg. The code has become a part of gaming culture, and many developers include it in their games as a nod to this history. The effects of the code in these games can vary widely.

Is the Konami Code used in any other media?

The Konami Code has been referenced in various forms of media, including movies, TV shows, and webcomics. It’s often used as a shorthand to indicate a character’s knowledge of video games or as a joke.

Why is the Konami Code so famous?

The Konami Code is famous because it was one of the first widely known video game cheat codes. Its easy-to-remember sequence and the fun of discovering what it does in different games have contributed to its enduring popularity.

Can the Konami Code be used on modern gaming consoles?

Yes, the Konami Code can be used on modern gaming consoles, as long as the game you’re playing includes it. The button sequence may vary slightly depending on the controller layout.

What happens if I enter the Konami Code incorrectly?

If you enter the Konami Code incorrectly, usually nothing will happen. You can simply try again. However, some games may have a different effect or Easter egg for incorrect entries.

Are there any other famous cheat codes like the Konami Code?

Yes, there are many other famous cheat codes in video games. Some examples include the “IDDQD” code for invincibility in Doom, the “motherlode” code for money in The Sims, and the “up, up, down, down, left, right, left, right, B, A, start” code for extra lives in Contra.

Andrew TetlawAndrew Tetlaw
View Author

iOS Developer, sometimes web developer and Technical Editor.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week