Robot/robot-js

Press multiple keys at the same time.

ninjabunny-dev opened this issue · 6 comments

I am working on a project where I need to press multiple keys at the same time. I have tried things like.

  keyboard.press(robot.KEY_W);
  keyboard.click(robot.KEY_S);
  keyboard.release(robot.KEY_W);

It doesn't hit them at the same time, I also fiddled with the autoDelay but this made the inputs unreliable. Is there a way to archive this? Any help will be much appreciated.

mmm that should work, I'm not sure why it's not working for you. What operating system is this?

I'm on Windows 10

I am trying to send keys one or two milliseconds apart. I think I might have to use the something lower level than node.

So the keyboard functions are blocking, so the send input's do get executed in the correct order. It's weird that it doesn't in your case.

I set keyboard.autoDelay.min = 10; keyboard.autoDelay.max = 30; and that seemed to do the trick

I'd see if you get the same problem in C++, using either robot or SendInput.