public IHotkeyCollection Add(Key key, ModifierKeys modifier, Action <Key, ModifierKeys> handler) { KeyModel hotkey = new KeyModel(modifier, key); HandlerList handlers; if (!storage.TryGetValue(hotkey, out handlers)) { handlers = new HandlerList((short)hotkey.GetHashCode()); if (Win32.RegisterHotKey(Handle, handlers.Atom, (uint)hotkey.Modifier, (uint)KeyInterop.VirtualKeyFromKey(hotkey.Key))) { storage[hotkey] = handlers; } else { throw new Win32Exception(Marshal.GetLastWin32Error()); } } handlers.Handlers.Add(handler); return(this); }