Javascript Detect Control Key Held on Mouseup

前端 未结 1 1087
天涯浪人
天涯浪人 2021-02-05 09:40

I\'ve searched a good deal, and can\'t seem to find a satisfactory solution. I hope someone can help.

While I am using jQuery, I am also writing many thousands of lines

1条回答
  •  情书的邮戳
    2021-02-05 10:08

    You can use the event.ctrlKey property.

    $(function(){
      $('#elementId').mouseup(function(e){
        var isCtrlPressed = e.ctrlKey;
        // true or false whether ctrl is pressed or not 
      });
    });
    

    Check a running example here.

    0 讨论(0)
提交回复
热议问题