JavaScript
Article
By Sam Deering

jQuery Konami Code Listener

By Sam Deering

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

--ADVERTISEMENT--

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account