Handle document key down event - Javascript DOM Event

Javascript examples for DOM Event:onkeydown

Description

Handle document key down event

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(){//from www . ja  v a2 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