title: Disable F5 Ctr+F5 and Ctrl+R in IE8 while input box is focused
body: <p>I want to disable web page refresh while text box is focused
  the code I'm using is this which works great for other shortcuts
  except that:</p>
  
  <p>BTW I want to achieve this by plain JavaScript no JQuery and no JavaScript 
  Frameworks.</p>
  
  <pre><code>  document.onkeydown = keyDown  //control chars
  document.onkeypress = keyDown   //any char/number
  
  function keyDown(e) {
  
          //74=j, 75=k, 78=n, 84=t
          var forbiddenCtrlKeys = new Array(74,75,78, 84);
          //37=left_arrow, 39=right_arrow
          var forbiddenAltKeys = new Array(37,39);
          //8=backspace, 116=F5
          var forbiddenSingleKeys = new Array(8,116);
          //per le textbox 116=F5
          var forbiddenTextBoxKeys = new Array(116);
  
          key = window.event.keyCode;     //IE
  
                if(window.event.ctrlKey){ //ctrl
                      isCtrl = true;
                      isAlt = false
  
                      checkVal(forbiddenCtrlKeys,window.event.keyCode);
                }
                else if(window.event.altKey){ //alt
                      isCtrl = false;
                      isAlt = true;
                      checkVal(forbiddenAltKeys,window.event.keyCode);
                }
  
                else{ //other
  
                      isCtrl = false;
                      isAlt = false;
                      var element = e.target.nodeName.toLowerCase();
                      var curr = document.activeElement
                      if(curr.tagName=="INPUT")
                      alert(curr.tagName);
  
                      if((element != 'input' &amp;&amp; element != 'textarea') || $(e.target).attr("readonly")){
                          alert(window.event.keyCode);
                          checkVal(forbiddenSingleKeys,window.event.keyCode); 
                      }
                      if(document.event.keyCode==116){
                          alert(window.event.keyCode);
                          document.event.keyCode=0;
                          checkVal(forbiddenTextBoxKeys,window.event.keyCode);
                      }       
                }
  }
  
  function checkVal(set,key){
  
  
          for(i in set)
          {
          //case-insensitive comparison
              if(String.fromCharCode(set[i]).toLowerCase() == String.fromCharCode(key).toLowerCase())
                          {
                                  alert('This key combination has been disabled.');
                                  window.event.returnValue =        false;    
                                  window.event.keyCode = 0;
                                  return true;
                          }
          }
  }
  </code></pre>
  
  <p>So what I've tried to achieve in the else case is whenever I try to press F5 disable it 
  but it doesn't works, any insight would be highly appreciated </p>