使用JavaScript或jquery我想仅捕获ctrl +鼠标左键单击事件以显示弹出窗口。想要仅使用ctrl键捕获此组合的任何其他内容都不应该被触发。
答案 0 :(得分:1)
click
事件具有ctrlKey
属性。如果它是true
按下了ctrl键。例如:
<button id="mybutton">click me + ctrl</button>
<script>
document.getElementById("mybutton").addEventListener("click", function () {
alert(event.ctrlKey ? "ctrl key pressed" : "ctrl key not pressed");
});
</script>
&#13;
答案 1 :(得分:1)
捕获click事件并检查ctrl是否已关闭。容易!
$("#div").click(function(event) {
if (event.ctrlKey) {
// ctrl + click is pressed
}
});