Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the keycode for "Shift + Arrow key"?

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.

like image 728
Akio Yanagawa Avatar asked Feb 21 '23 22:02

Akio Yanagawa


1 Answers

The shiftKey property indicates that the shift key is pressed:

$('body').trigger(jQuery.Event('keydown', { keycode:38, shiftKey: true }));
like image 73
Adam Rackis Avatar answered Mar 06 '23 07:03

Adam Rackis