moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.74k stars 244 forks source link

Hotkey not working according to expected common behaviour #536

Open GautierBlandin opened 1 year ago

GautierBlandin commented 1 year ago

Description If two hotkeys are setup, one to activate when pressing shift+q, the other by pressing only q, the behaviour expected by the user is that pressing shift+q will trigger the shift+q hotkey but NOT the q only hotkey. However, using pynput global hotkeys, BOTH hotkeys are triggered.

Another common expected behaviour in hotkeys is that pressing modifiers keys should not trigger the hotkey. For example, pressing ctrl+c to copy and ctrl+v to paste are usual hotkeys. However, when pressing c+ctrl (in that order), the user doesn't expect the hotkey to be triggered.

Platform and pynput version Windows, latest

To Reproduce Create global hotkeys and perform the actions described above.

Proposed fix I have a partial fix ready that modifies the press method of the hotkey class. Does this repo accept pull requests ? The fix consists in modifying the _on_press method of the Hotkey class to behave according to the specified expected behaviors.

moses-palmer commented 1 year ago

Thank you for your suggestion!

Yes, this repository does accept pull requests! Please submit, and I will review.