0

Is there a simple solution without jquery, inside HTML-tags to catch a CTRL+Mouseclick?

It could look like this:

<a href="#" onclick="if(ctrl_is_pressed()) alert('CTRL+Mouseclick');">X</a>
rubo77
  • 19,527
  • 31
  • 134
  • 226
  • 2
    I asume this is to prevent the anchor opening in a new tab/window. Unless you have a **very good** reason for this, dont change browser behaviour. It will hurt the user experience more than it does any good – Martijn Sep 09 '13 at 14:13
  • I want to use the X as a close button, except in case CTRL is pressed too – rubo77 Sep 09 '13 at 16:57

1 Answers1

7

In the event object, there's a ctrlKey property.

<a href="#" onclick="if(event.ctrlKey) alert('CTRL+Mouseclick');">X</a>
gen_Eric
  • 223,194
  • 41
  • 299
  • 337