﻿document.onkeypress = shortcutKey;

function checkTag(e) {
     elm = (e.target) ? e.target : ((e.srcElement) ? e.srcElement : null);
     ng = new RegExp("input|select|textarea", "i");
     if(elm.tagName && elm.tagName.match(ng)) {return true;}
}

function shortcutKey(e) {
     e = (e) ? e : ((event) ? event : null);
     if (checkTag(e)) { return true; }
     k = (e.charCode) ? e.charCode : ((e.which) ? e.which : e.keyCode);
     switch(k) {
          case 98:
          case 66:
          case 112:
          case 80:
               if(bURL) location.href = bURL;
               break;
          case 110:
          case 78:
               if(nURL) location.href = nURL;
               break;
          default:
     }
}
