octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.4k stars 971 forks source link

Using "keyTap" while a modifier is physically held results in unexpected behaviour #689

Open ghost opened 3 years ago

ghost commented 3 years ago

Current Behavior

Running keyTap while a physical modifier is pressed results in "modifier+key" or nothing, instead of the "key" only.

globalShortcut.register('CommandOrControl+M', () => {
    console.log('tap');
    robot.keyTap('5');
  });

This sends "Ctrl-5" sometimes (maybe), but doesn't work most of the time.

This works fine on the other hand:

globalShortcut.register('CommandOrControl+M', () => {
    console.log('tap');
    setTimeout(() => {
      robot.keyTap('5');
    }, 2000); 
  });

Here if I unpress the modifier it sends "5" reliably. If I continue pressing "Ctrl", sends "Ctrl+5" reliably.

Your Environment