TolikPylypchuk / SharpHook

SharpHook provides a cross-platform global keyboard and mouse hook, event simulation, and text entry simulation for .NET
https://sharphook.tolik.io
MIT License
347 stars 32 forks source link

Handling keyboard shortcuts #88

Closed Scorfox closed 8 months ago

Scorfox commented 8 months ago

Hi! Can I handle keyboard shortcuts (for example CTRL+TAB, ALT+ESC, etc) using your library?

TolikPylypchuk commented 8 months ago

Hi! Thanks for asking! SharpHook itself doesn't have any helper classes for handling key combinations, but it's absolutely possible to create your own, especially with SharpHook.Reactive.

As an example, you can look at how I use SharpHook.Reactive to handle key combinations of modifier keys (but it can be extended to any key) with the ability to handle multiple presses of the key combination (e.g. Ctrl+Shift pressed twice): https://github.com/TolikPylypchuk/KeyboardSwitch/blob/main/src/KeyboardSwitch.Core/Services/Hook/SharpHookService.cs

Scorfox commented 8 months ago

This looks cool! I'll try it, thanks!