Jquery run a shortcut

Asked

Viewed 194 times

1

I need to perform this screen minimize shortcut:

Alt+shift+n

Is there any way to perform this after a click on the button?

$("#btnVoltar").click(function(){
    var ALT =   18;
    var space = 32;
    var n = 78;
.....
  • What an interesting question, since there is no way to minimize the screen with javascript, I did a similar question in the main community, so I get the answer give you a feedback

  • Whoa, thanks, bro, thanks for your help.

  • Ricardo posted a solution, I’ll get home and test , if it’s right, I’ll send you too

1 answer

0

That code does it:

var press = jQuery.Event("keypress");
press.which = 78;  // tecla n
press.shiftKey = true;  // shift pressionado
press.altKey = true;  // alt pressionado
$("algumElemento").trigger(press);  // aqui "dispara" as teclas sobre algum elemento

I hope it helps.

  • I’ll test it here, bro, thanks.

  • I didn’t know that command

  • It is very interesting, I already used to fire CTRL + D to add a link to the browser bookmarks.

  • That would be @Ricardo $(function(){
 $("#btnClick").click(function(){
 var press = jQuery.Event("keypress");
 press.which = 78; // tecla n
 press.shiftKey = true; // shift pressionado
 press.altKey = true; // alt pressionado
 $(this).trigger(press); // aqui "dispara" as teclas sobre algum elemento
 });

 });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.