Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shift mouse click trigger

I can trigger click event on element selector using trigger

$('element selector').trigger('click')

Is it possible to trigger shift click. I mean shift + left mouse click.

like image 792
Maxim Yefremov Avatar asked Mar 06 '15 09:03

Maxim Yefremov


1 Answers

try

var shiftClick = jQuery.Event("click");
shiftClick.shiftKey = true;

$("element selector").click(function(event) {
    if (event.shiftKey) {
       alert("Shift key is pressed");
    }
    else {
       alert('No shift hey');
    }
});

$("element selector").trigger(shiftClick);

JSFiddle

like image 160
alquist42 Avatar answered Nov 17 '22 05:11

alquist42