Reputation: 2866
Say I have three different functions bound to three different global hotkeys...
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.
Upvotes: 0
Views: 484
Reputation: 5733
Why not make the hotkey class static?
Hotkey.Register(modifier, key, callback)
and keep them in a list within the class?
Also, I would recommend adding more modifiers to your hotkeys. All of yours are assigned to a common task: Control+P = Print, Control+N = New and Control+V = Paste
Upvotes: 0