octalmage / robotjs

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

On Windows, LSHIFT keytap is sent when using `right_shift` #703

Open Madrox opened 2 years ago

Madrox commented 2 years ago

Expected Behavior

When sending a keyTap or keyToggle event with a shift modifier, the proper shift key should be sent.

Current Behavior

Currently, lshift is called. This is likely also occuring with other modifiers like ctrl, as the switch logic collapses left vs right into a general modifier.

Possible Solution

Either refactor the modifier logic to distinguish between left and right to send the appropriate key press, or eliminate the right_shift modifier and retain shift as its inclusion is misleading.

Steps to Reproduce (for bugs)

  1. Install a windows key logging tool such as ShowOff: https://www.dcmembers.com/skrommel/download/showoff/
  2. Launch and observe the result of keyTap("f11", ["right_shift"])
  3. Notice LShift is the modifier

Context

I'm simulating the keypress of a global shortcut, and to distinguish it from normal user behavior in their current app, it should be bound purely to the right shift key (which is never used in their context).

Your Environment

Madrox commented 2 years ago

By switching logic, I mean this code here: https://github.com/octalmage/robotjs/blob/c9cbd98ec47378dfae62871f0f2830782322b06d/src/robotjs.cc#L429

At this point, it seems the intented left/right keypress modifier is lost.