Konami Code

Here is the source code to put in your website to enable konami code sequence
On your keyboard press (in this order): Up, Up, Down, Down, Left, Right, Left, Right, B, A … then wait a sec.


              <html>
<head>
<!-- Konami Code -->
<script type="text/javascript">
function onKonamiCode(fn) {
    var codes = (function(){
            var c = [38,38,40,40,37,39,37,39,66,65];
            onKonamiCode.requireEnterKey && c.push(13);
            return c;
        })(),
        expecting = function(){
            expecting.codes = expecting.codes || Array.apply({}, codes);
            expecting.reset = function() { expecting.codes = null; };
            return expecting.codes;
        },
        handler = function(e) {
            if (expecting()[0] == (e||window.event).keyCode) {
                expecting().shift();
                if (!expecting().length) {
                    expecting.reset();
                    fn();
                }
            } else { expecting.reset(); }
        };
    window.addEventListener ?
        window.addEventListener('keydown', handler, false)
        : document.attachEvent('onkeydown', handler);
}


onKonamiCode.requireEnterKey = false; // True/false
onKonamiCode(function(){
    // Do something CRAZY!
alert('You just Entered Konami Code');
});
</script>
</head>
<body>
<h2>hi</h2></body></html>

The Konami Code, known in Japan as the Konami Command (コナミコマンド Konami Komando?), is a cheat code that appears in many Konami video games,[1] although the code also appears in some non-Konami games.[2] The code was first used in the 1986 release of Gradius for the Nintendo Entertainment System[3] but was popularized among North American players in the NES version of Contra, for which it was also dubbed both the "Contra Code" and "30 Lives Code". During the title screen before the game demo begins, the player could press the following sequence of buttons on the game controller:

Comments