Recently, many sites (such as espn.com and facebook.com) have added Easter eggs to their JavaScript libraries that are triggered by the old Konami video game code: up up down down left right left right b a enter. While this does not necessarily improve the web architecture, it does make it more fun. To promote more easter eggs like that, I decided to write a simple script that makes integrating the Konami code into your site trivial.

This requires including YUI for event handling and custom events. The code listens for key strokes on the document, recording the desired keys in the appropriate order. The developer need only subscribe to the public CustomEvent onCodeEntered, allowing any number of callback functions.