Konami code on your website

Konami code on your website

The Konami Code is a cheat code that can be used in many Konami video games, usually activating a secret option. This code was used for the first time in 1986 (I was not yet born) in Gradius for the Nintendo Entertainment System. During the game, the player must press the following sequence of buttons on the game controller:![code-konami.png](1-content.png).

This code is functional on this web site, I'll let you see the effect.

For this tutorial you will need:

  • HTML basics
  • Programming concepts (conditions, functions and loops, arrays)
  • jQuery
  • Some french skills because the video tutorial is in french

See you soon for another tutorial.

You can find the source code of the plugin below:

(function($){
   $.fn.konami = function(callback, code){
   if(code === undefined) code="38,38,40,40,37,39,37,39,66,65";
      this.each(function(){
         var kkeys = [];
         $(this).keydown(function(e){
            kkeys.push(e.keyCode);
            if(kkeys.toString().indexOf(code) >= 0){
               kkeys = [];
               callback();
            }
         });
       });
    }
})(jQuery);