Be sure to check out the latest release of the plugin!

One of the things that I love about working on side projects is that they can be just as complex or simple, or as fun or mundane as you want them to be.

Case in point: A couple of years ago when 8BIT was first getting started, we had a really simple landing page, but we had the idea to incorporate something fun.

Considering we all group up during the 8-bit era of video games, we opted to incorporate the Konami code into our site. So I wrote a small jQuery plugin that makes it really easy to include the cheat code into your site or web application.

Simply put, it’s the jQuery Konami Code.

jQuery Konami Code

Grab the JavaScript-based cheat code on GitHub

This morning, I spent a little bit of time refactoring the code and bringing it up to JSLint standards, as well as migrating the README and the CHANGELOG to markdown to make for a bit easier reading on the GitHub landing page.

Additionally, I moved the license – that is, the MIT License – to the README itself and removed the redundant file from the repository.

Using The jQuery Konami Code

It’s really simple – even if you’re not familiar with JavaScript or jQuery, you should be able to get up and going relatively quickly.

1. Include jQuery

If your project doesn’t already include jQuery, make sure that you include it in the `head` element of your page:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>[/html</pre>
<h3>2. Include the Konami Code plugin</h3>
<pre>
Next, include the Konami Code plugin just under the jQuery library: [html]<script type="text/javascript" src="jquery.konami.min.js"></script>

3. Write Your Custom Behavior

At this point, you’re ready to write what happens when users enter your cheat. Simply put, you just need to apply the `konami` function to the `window` object, then define a function that makes something, y’know, happen when the cheat code is entered.

For example:

 $( window ).konami({
        cheat: function() {
            alert( 'Cheat code activated!' );
        }
});

In the code above, a simple alert dialog will appear whenever the cheat code is entered.

The repository even includes a simple demo showing exactly how to get started. You can download an archive of the entire script and the demo here.

Anyway, simple, but fun, right? Enjoy.