disable keyboard's ContextMenu function with javascript in webpage - Javascript DOM

Javascript examples for DOM:Key Event

Description

disable keyboard's ContextMenu function with javascript in webpage

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*w w w  .j a  v  a 2 s .  c  om*/
var keypressed = false;
window.addEventListener ("keydown",function (e) {
   if (e.keyCode === 93) 
      keypressed = true;
});
window.addEventListener ("contextmenu",function (e) {
    if (keypressed) {
         e.preventDefault(e);
         keypressed = false;
    }
})
    }

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

Related Tutorials