  //mouse right click
  document.oncontextmenu = returnFalse;
  //F1
  document.onhelp = returnFalse;

  // handle mouse control
  document.onmousewheel = captureMouseWheel;

  function returnFalse(){
    return false;
  }

  document.onkeydown = captureAction;

// capture the action
  function captureAction(e){
    var evt = e || event;
    if (isFunctionKey(evt) || isAltLeftOrRight(evt) || isBackspace(evt) || 
        isInvalidControlKey(evt)
       ) {
      return false;
    }
  }

//if F2 - F12 is pressed (for IE only)
  function isFunctionKey(e) {
    if ((e.keyCode > 112) && (e.keyCode < 124)) {
      try {
        e.keyCode = 0;
      } catch (e) {
        // ignore - e.keyCode is not supposed to be writable accding to DOM,
        // but we do it so that it would work on IE
      }
      return true;
    }
    return false;
  }

//if backspace is pressed
  function isBackspace(e) {
    var elt = document.activeElement || e.target;
    var sActiveElement = elt.type;
    if (e.keyCode == 8 && (
        (sActiveElement != "text") && (sActiveElement != "file") && 
        (sActiveElement != "textarea") && (sActiveElement != "password"))
       ) {
      return true;
    }
    return false; 
  }

//if key pressed is alt-left or alt-right  
  function isAltLeftOrRight(e) {
    if (e.altKey && (e.keyCode == 37 || e.keyCode == 39)) {
      return true;
    }
    return false;
  }

//if Ctrl + any key (except for "F","C","V"). works only for IE
  function isInvalidControlKey(e) {
    //70:Ctrl-F; 67:Ctrl-C; 86:Ctrl-V; 88:Ctrl-X
    if (e.ctrlKey && ((e.keyCode != 70) && (e.keyCode != 67) && (e.keyCode != 86) && (e.keyCode != 88))) {
      return true;
    }
    return false;
  }

// capture the mousewheel to prevent scrolling through previous pages
  function captureMouseWheel(e){
    var evt = e || event
    return (!evt.shiftKey);
  }

