I want to write a script which triggers an artificial keydown event (Shift + Arrow key) when button is clicked in jQuery.
$('button').click(function(){
$('body').trigger(jQuery.Event('keydown', {keycode:16})); //This line triggers a keydown for 'Shift'.//
$('body').trigger(jQuery.Event('keydown', {keycode:38})); //This line triggers a keydown for 'Up Arrow key'.//
});
Is there a way to combain these two? That is, is there a key code for 'Shift + Arrow key' or any script for this to be done? I would appreciate any responses. Thank you.
The shiftKey
property indicates that the shift key is pressed:
$('body').trigger(jQuery.Event('keydown', { keycode:38, shiftKey: true }));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With