Shift + mouseover with jQuery

前端 未结 4 1257
再見小時候
再見小時候 2021-02-20 13:34

I\'m trying to detect whether the shift key is being pressed while the cursor is moved over a particular element. The function fires, but only after I click on another

4条回答
  •  悲&欢浪女
    2021-02-20 13:52

    It is not necessary to store in a variable when the shift key is pressed and released. You can achieve what you are trying to to like this:

    $('#selector').mouseover(
        function(e){
            if (e.shiftKey)
            {
                console.log("the shift key is pressed");
            }
        }
    );
    

提交回复
热议问题