Use keydown event without affecting all keys - Javascript DOM Event

Javascript examples for DOM Event:ctrlKey

Description

Use keydown event without affecting all keys

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 o  m
function KeyPress(e) {
      var evtobj = window.event? event : e
      if (evtobj.keyCode == 90 && evtobj.ctrlKey) console.log("Ctrl+z");
}
document.onkeydown = KeyPress;
    }

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

Related Tutorials