document.onkeyup = alertkey;

string = '';

valid = ["up","down","left","right","B","A"];

function alertkey(e) {
  if( typeof( e.keyCode ) == 'number'  ) {
    //DOM
    e = e.keyCode;
  } else if( typeof( e.which ) == 'number' ) {
    //NS 4 compatible
    e = e.which;
  } else if( typeof( e.charCode ) == 'number'  ) {
    //also NS 6+, Mozilla 0.9+
    e = e.charCode;
  } else {
    //total failure, we have no way of obtaining the key code
    return;
  }
  if (e == 38) {
    lolz = "up";
  }
  else if (e == 37) {
    lolz = "left";
  }
  else if (e == 39) {
    lolz = "right";
  }
  else if (e == 40) {
    lolz = "down";
  }
  else {
    lolz = String.fromCharCode(e);
  }

  for (i=0;i<valid.length;i++) {
    if (valid[i] == lolz) {
      dix = 1;
      break;
    }
    else { dix = 0; }
  }

  if (dix == 1) { string = string + lolz; }
  else { string = ''; }

  if (string == "upupdowndownleftrightleftrightBA") { 
    window.location = "konami.html"
    string = '';
  }
}

