src/Windows/Forms/0/src/Hooks/KeyboardHookManager.cs
/// <summary>
/// Registers a hotkey. To register only a modifier: set it as <see cref="KeyEventArgs.KeyCode"/>.
/// </summary>
/// <param name="args"></param>
/// <returns>Hotkey id. You have to unregister it.</returns>
Registers a hotkey. To register only a modifier: set it as .
Registers a hotkey . To register only a modifier : set it as .
public ChildHotkey RegisterHotkey(KeyEventArgs args)
        {
            ParentHotkeyInvoker? hotkeyInvoker = null;
            if (!registeredHotkeys.Any((x) => {
                if (x.Value.KeyEventArgs.Modifiers == args.Modifiers && x.Value.KeyEventArgs.KeyCode == args.KeyCode) {
                    hotkeyInvoker = x.Value;
                    return true;
                }
                return false;
            })) {
                if (registeredHotkeys.Count == 0) {
                    start();
                }
                int id = 0;
                do {
                    id++;
                } while (registeredHotkeys.Any(x => x.Value.Id == id));
                hotkeyInvoker = ParentHotkeyInvoker.Create(id, args, (childHotkey) => UnregisterHotkey(id));
                registeredHotkeys.Add(id, hotkeyInvoker);
                return hotkeyInvoker.RegisterChildren();
            } else {
                hotkeyInvoker.Counter++;
                return hotkeyInvoker.RegisterChildren();
            }
        }
public ChildHotkey RegisterHotkey ( KeyEventArgs args ) { ParentHotkeyInvoker ? hotkeyInvoker = null ; if ( ! registeredHotkeys . Any ( ( x ) => { if ( x . Value . KeyEventArgs . Modifiers == args . Modifiers && x . Value . KeyEventArgs . KeyCode == args . KeyCode ) { hotkeyInvoker = x . Value ; return true ; } return false ; } ) ) { if ( registeredHotkeys . Count == 0 ) { start ( ) ; } int id = 0 ; do { id ++ ; } while ( registeredHotkeys . Any ( x => x . Value . Id == id ) ) ; hotkeyInvoker = ParentHotkeyInvoker . Create ( id , args , ( childHotkey ) => UnregisterHotkey ( id ) ) ; registeredHotkeys . Add ( id , hotkeyInvoker ) ; return hotkeyInvoker . RegisterChildren ( ) ; } else { hotkeyInvoker . Counter ++ ; return hotkeyInvoker . RegisterChildren ( ) ; } }
Registers a hotkey.
Registers a hotkey .
//
Hotkey id. You have to unregister it.
Hotkey id . You have to unregister it .
args
KeyEventArgs
None