moses-palmer / pynput

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

Added '<*>' Hotkey to allow for on_press action #491

Closed StephenArg closed 2 years ago

StephenArg commented 2 years ago

I noticed an issue where I was unable to have a normal keyboard Listener active while also using GlobalHotKeys. I only needed both listeners because I wanted HotKeys and the on_press command available to me at the same time. This was my solution.

Example case:

keyboard_listener = keyboard.GlobalHotKeys({
                 '<cmd>+<ctrl>+m': do_something,
                 '<alt>+s': something_else,
                 '<*>': runs_every_click
         })
keyboard_listener.start()

If you have any suggestions, improvements, ideas, or insults, please let me know. I like your python package and I'd like to contribute however I can.

StephenArg commented 2 years ago

Adding the issue I made earlier about this https://github.com/moses-palmer/pynput/issues/490#issue-1313825888

moses-palmer commented 2 years ago

Thank you for your contribution!

As per my comment on #490, this is solvable using the current API, and to be frank, I'd rather not clutter the implementation with special casing of the magic incantation '<*>'. I am looking forward to future pull requests from you, but this one I will unfortunately decline!