0
votes

I would like to make 3 buttons to activate a simulated key press of "Alt+o", "Alt+w" and "Alt+c" inside HTML in Internet Explorer.

Explanation of what I want to do- I have made a website that handles various things and now trying to activate a background program. I have installed AutoHotKey and I can get these buttons to work with the keyboard but I want to run this without a keyboard attached.

I have found 2 other similar responses on here but I could not make them work and as they were older threads I thought I would start a new thread to see what is out there.

EDIT: I don't want pressing Alt+o key to trigger something (I already have that), I want the reverse, a button that triggers (simulates) Alt+o key combination

1
Would you link us to the old threads you've found.Stark

1 Answers

0
votes

you can do something like that.

  $('<selector element>').keydown(function(e){
       var arrayOfCharcode=[111,99,119];//ascii codes need to be allowed
       if(e.altKey && arrayOfCharcode.indexOf(e.which)>=0){
          e.preventDefault();
           prompt("Alt+<charcode ascii>, Enter","text");
       }
   });

you can do that in your case

$(document).keydown(function(e){
       var arrayOfCharcode=[99,111,119,68,79,87];//ascii codes need to be allowed
       if(e.altKey && arrayOfCharcode.indexOf(e.which)>=0){
          e.preventDefault();
          switch(e.which){
              case 99:
              case 68:
                    //call button1 function  alt + c
                break;
            case 111:
            case 79:
                    //call button2 function alt + o
                break;
            case 119:
            case 87:
                    //call button3 function alt +w
                break;
          }
       }
   });