I clearly spent a little too long thinking about this, but it was fun nonetheless!

I showed my 5-year-old nephew the construction cheat in Sonic the Hedgehog the other weekend and he thoroughly enjoyed printing rocks everywhere on the screen, so I wondered if it would be possible to do something similar in JavaScript, since people love using the Konami code for easter eggs, why not Sonic?

I opted for native javascript, not using any libraries for easy portability.

I’ve encountered a few issues on some sites that already capture keypresses, but for the most part it’s worked ok. I’ve only tested this on Chrome and Firefox (Mac, latest versions) but it should work fine on Windows. No idea about IE… Probably not, but I did try to use cross-browser methods where applicable!

The commented source is here and the script is enabled on the blog so you should be able to use it anywhere.

Have fun!

Oh, here are some sprites for good measure:

For those that need reminding of the code (I’m not angry, just disappointed):