admin管理员组文章数量:1430941
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>
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>
Share
Improve this question
asked Sep 9, 2013 at 14:05
rubo77rubo77
21k33 gold badges148 silver badges240 bronze badges
2
- 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 Commented Sep 9, 2013 at 14:13
- I want to use the X as a close button, except in case CTRL is pressed too – rubo77 Commented Sep 9, 2013 at 16:57
1 Answer
Reset to default 7In the event
object, there's a ctrlKey
property.
<a href="#" onclick="if(event.ctrlKey) alert('CTRL+Mouseclick');">X</a>
本文标签: javascriptCatch onclickevent with CTRL pressedStack Overflow
版权声明:本文标题:javascript - Catch onclick-event with CTRL pressed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745562713a2663569.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论