Way to trigger multiple keypress and hold events in jQuery

With the modifier keys alt, ctrl, and shift, you can use event modifiers specifically for them:

$(".f1").click(function() {
    var e = jQuery.Event("keydown");
    e.which = 112;       // # F1 code value
    e.altKey = true;     // Alt key pressed
    $("input").trigger(e);
});

Demo: http://jsfiddle.net/jtbowden/2kcrg/

Leave a Comment