What's a good design to handle multiple global hotkeys?
Posted
by
Alex
on Stack Overflow
See other posts from Stack Overflow
or by Alex
Published on 2012-10-13T21:34:28Z
Indexed on
2012/10/13
21:36 UTC
Read the original article
Hit count: 366
I'm struggling to think of a good design to handle multiple global hotkeys.
Say I have three different functions bound to three different global hotkeys...
- Play Song | Ctrl + P
- Skip Song | Ctrl + N
- Increase Volume | Ctrl + V
What's a good, effective way to check if the hotkey pressed conforms to a certain function? I'm using a class very similar to this: http://www.liensberger.it/web/blog/?p=207
Should I create a new instance of the hotkey class for each hotkey?
Hotkey hotkey = new Hotkey();
hotkey.RegisterHotkey(Shortcut.ModifierKeys.Control, Keys.F10);
hotkey.KeyPressed += ((s, args) =>
{
//Do Something!
});
Or should I have an enum with different hotkey functions and manage it from within the hotkey class to prevent multiple instances (seems wasteful but easy). Thanks for any advice / help in advance.
© Stack Overflow or respective owner