robot-js icon indicating copy to clipboard operation
robot-js copied to clipboard

Press multiple keys at the same time.

Open ninjabunny-dev opened this issue 7 years ago • 7 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.

ninjabunny-dev avatar Jun 13 '18 18:06 ninjabunny-dev

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

dkrutsko avatar Jun 13 '18 21:06 dkrutsko

I'm on Windows 10

ninjabunny-dev avatar Jun 13 '18 21:06 ninjabunny-dev

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

ninjabunny-dev avatar Jun 13 '18 21:06 ninjabunny-dev

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.

dkrutsko avatar Jun 13 '18 21:06 dkrutsko

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

ninjabunny-dev avatar Jun 13 '18 22:06 ninjabunny-dev

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

dkrutsko avatar Jun 14 '18 00:06 dkrutsko