1

I was wondering if anyone could point me in the right direction. I'm building a Node app that I want to execute some hotkeys on the computer it's running on to start & stop an OBS stream based on hotkeys.

I was wondering if this is possible as I've only been able to find out of date and non-working solutions.

Thanks.

1 Answers1

2

You can do it easily in AutoHotKey, but if it is Node you need, Node you'll get.

Probably quite a few Node Package Managers (NPM's) that will fit the bill, if you check github, I'm betting someone has made a little something something.
Lo and behold, I did it for you : hott - Global hotkeys for Windows, with node

Seems a tad overkill to me, using "iohook" should work wonders; hook it up in the semi-old fashion JS way of the event, something like so :

The only way I am fairly certain will work is plain and simple event listening :

const ioHook = require('iohook');
ioHook.on("keypress", event => {
    if(event.keychar == 'a') {
        console.log(event);
    } else {
        console.log("Press a");
    }
  });
ioHook.start();
Morten Bergfall
  • 2,296
  • 4
  • 20
  • 35
  • I like that you say "Node you'll get" instead of providing an example that won't suit the question. You have my upvote. – SuperJumpBros Apr 02 '22 at 21:11