Check which key is pressed and which mouse button is click in onkeydown event - Javascript DOM

Javascript examples for DOM:Key Event

Description

Check which key is pressed and which mouse button is click in onkeydown event

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. java 2  s . c  om
      <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