Check if the control key is pressed in click event - Javascript DOM Event

Javascript examples for DOM Event:onkeypress

Description

Check if the control key is pressed in click 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">
function doAjax(e) {/* w ww .  jav  a 2s  .  c  om*/
    if (!e) e = window.event;
    if (!e.ctrlKey) {
        console.log("Ajax code here");
        return false;
    }
}

      </script> 
   </head> 
   <body>
       Here is a 
      <a href="/link/location" onclick="return doAjax(event);">link</a>  
   </body>
</html>

Related Tutorials