View Single Post
  #5 (permalink)  
Old 11-26-09, 08:42 AM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
javascript Code:
  1. // check to make sure that the browser can handle window.addEventListener
  2. if (window.addEventListener) {
  3.     // create the keys and konami variables
  4.     var keys = [],
  5.         konami = "38,38,40,40,37,39,37,39,66,65";
  6.  
  7.     // bind the keydown event to the Konami function
  8.     window.addEventListener("keydown", function(e){
  9.         // push the keycode to the 'keys' array
  10.         keys.push(e.keyCode);
  11.  
  12.         // and check to see if the user has entered the Konami code
  13.         if (keys.toString().indexOf(konami) >= 0) {
  14.             // add Easter Egg here:
  15.  
  16.             // and finally clean up the keys array
  17.             keys = [];
  18.         };
  19.     }, true);
  20. };

Found at:

Matt Kirman / How to recreate the Konami code in Javascript
Reply With Quote