0

I was wondering if there is a way to make JavaScript execute keyboard combinations.

I am making an application in Electron and I can't get my custom Minimize and Maximize buttons to work on Windows. I tried running the application on Mac and it works perfectly. So I was thinking about just making a button that can execute keyboard commands.

unor
  • 92,415
  • 26
  • 211
  • 360
feen
  • 47
  • 1
  • 6
  • 2
    Possible duplicate of [Simulate JavaScript Key Events](http://stackoverflow.com/questions/596481/simulate-javascript-key-events) – Caleb Anthony Aug 01 '16 at 21:39

1 Answers1

0

It would be alt+space+n to minimize but secure reasons I guess it won't work.

$("#minimize").click(function() {
    var e = jQuery.Event("keydown");
    //e.which = 115;       // # F4 code value
    e.altKey = true;     // Alt key pressed
    e.which = 32;      //space key
    //e.which = 78;      //n key
    $("#minimize").trigger(e);

});
Leroy Thompson
  • 470
  • 3
  • 13