JavaScript - - By Sam Deering

jQuery Konami Code Listener

jQuery code snippet that listens for entry of a Japanese Konami code and then performs your desired action.

if ( window.addEventListener ) {
    var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
    window.addEventListener("keydown", function(e){
        kkeys.push( e.keyCode );
        if ( kkeys.toString().indexOf( konami ) >= 0 )
            // User entered Konami Code, do something cool!!!
            kkeys = [];
    }, true);
}

More info on Konami plugins here: http://plugins.jquery.com/project/konamiCode

Sponsors