Disable key event by returning false from onkeydown - Javascript DOM

Javascript examples for DOM:Key Event

Description

Disable key event by returning false from onkeydown

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width"> 
   </head> 
   <body>
       No developer toolbar //from   w  ww.j  a v a  2s  .c o  m
      <script>
window.oncontextmenu = function () {
   return false;
}
document.onkeydown = function (e) {
    if (window.event.keyCode == 123 ||  e.button==2)
    return false;
}

      </script>  
   </body>
</html>

Related Tutorials