octalmage / robotjs

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

keyToggle not working with modifier keys (mac) #691

Open nickretallack opened 2 years ago

nickretallack commented 2 years ago

Expected Behavior

robot.keyToggle("shift", "down") should hold down the Shift key.

Current Behavior

It doesn't hold it down long enough to modify the next keyboard event. Seems similar to these issues: https://github.com/octalmage/robotjs/issues/132 https://github.com/octalmage/robotjs/issues/683

Possible Solution

Fix it? Or don't. What I really want is to do a is command+click, so if we implemented passing modifier keys to mouseClick and mouseToggle that would serve my use case. This was brought up in https://github.com/octalmage/robotjs/issues/355 but the work-around there isn't working for me because keyToggle doesn't appear to work for modifier keys on my mac.

Steps to Reproduce (for bugs)

If I run this script, it types "a".

robot.keyToggle("shift", "down")
robot.keyTap("a")

But if I run this script, it types "A".

robot.keyTap("a", ["shift"])

This just does a regular click, not a shift+click.

robot.keyToggle("shift", "down")
robot.mouseClick()

Context

I want to be able to command+click.

Your Environment

theashishmaurya commented 1 year ago

Did it got fixed?