Open mzmiric5 opened 7 years ago
Further research indicates that on macOS, none of the keystrokes seem to be simulated globally, but only to the app that has focus.
I've found that in some apps the modifier values might appear different to those expected.
Some examples of what the further research resulted in: In GameShow:
In Discord:
In OBS:
I am assuming that the app having to be focused issue is caused by the Quartz Event simulating the keypress only sending the event to the application that is in foreground/focused.
Did you ever find a workaround for this issue?
Unfortunately no. We even tried switching the type of the keypress event that robotjs sends, with no luck
This issue has been closed because it has been inactive for > 180 days. You may reopen this issue if it has been closed in error.
Still a problem
Seems like sending a keystroke combination on macOS is not consistent in all applications. For example, sending Cmd+T with Chrome focused, opens a new tab, sending Cmd+B with Word focused, bolds the text, sending Cmd+/ with Atom focused, comments out the selected line. These all work as expected. But trying to send custom defined hotkeys to apps like OBS, GameShow or Discord results in any keystroke combo including any of the modifiers to not work. Sending a single key with no modifiers seems to only work if the specific app is focused. The custom hotkeys defined in those apps normally work regardless of the app being focused. On Windows, this works without any issues, so the problem seems to be OS specific to macOS.
Expected Behavior
Sending a keystroke combination should result in the same global behaviour that results from pressing that keystroke combination on keyboard both on Windows and macOS.
Current Behavior
Behaviour not consistent, and not captureable with Keyboard Viewer on macOS. Any custom global hotkeys don't seem to be responding to the keystroke combination being sent from node code if they include modifiers. Single key hotkey without modifiers seem to work if the targeted app is in focus. While this is the case on macOS, this problem does not exist on Windows.
Steps to Reproduce (for bugs)
robot.keyTap('2', ['alt']); // send an alt + 2 keystroke combination