JQuery or [removed] How determine if shift key being pressed while clicking anchor tag hyperlink?

前端 未结 12 2041
别那么骄傲
别那么骄傲 2020-11-27 03:00

I have an anchor tag that calls a JavaScript function.

With or without JQuery how do I determine if the shift key is down while the link is clicked?

The foll

12条回答
  •  隐瞒了意图╮
    2020-11-27 03:51

    I had a similar problem, trying to capture a 'shift+click' but since I was using a third party control with a callback rather than the standard click handler, I didn't have access to the event object and its associated e.shiftKey.

    I ended up handling the mouse down event to record the shift-ness and then using it later in my callback.

        var shiftHeld = false;
        $('#control').on('mousedown', function (e) { shiftHeld = e.shiftKey });
    

    Posted just in case someone else ends up here searching for a solution to this problem.

提交回复
热议问题