Categories
Development

Konami Code – Javascript Code

Konami Code (Jap – Command) is a cheat code that appears in many Konami video games, although the code also appears in some non-Konami games. The code has also found a place in popular culture as a reference to the third generation of video game consoles. This is the javascript that you can implement into your open development to add easter eggs to your code.
This is the sequence of the code:
up, up, down, down, left, right, left, right, B, A


<script type="text/javascript">
//<![CDATA[
if(window.addEventListener)
{
   var keys=[],konami="38,38,40,40,37,39,37,39,66,65";
   window.addEventListener("keydown",function(e){
      keys.push(e.keyCode);
      if(keys.toString().indexOf(konami)>=0) {
         (function(){alert('Konami');})();
         keys=[];
      };
   },true);
};
// ]]>
</script>

One reply on “Konami Code – Javascript Code”