How to register a custom keyboard shortcut for a windows application How to register a custom keyboard shortcut for a windows application windows windows

How to register a custom keyboard shortcut for a windows application


An option for doing that programatically when your application start is calling this Windows API:

RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

And to unregister call this API:

UnregisterHotKey(IntPtr hwnd, int id);

Both exist in user32 APIs

http://www.pinvoke.net/search.aspx?search=RegisterHotKey&namespace=[All]


If you need more advanced scenario to what the shell shortcut offer, you should start with reading Win32 Hooks and Hooks Overview.

More specifically, you need to add a WH_KEYBOARD hook using the SetWindowsHookEx function. You also need to unhook through UnhookWindowsHookEx when you are done.

There's an old article from Dino Esposito how to do Windows Hooks in .NET through some Win32 interop.


If your application (or a shortcut to it) is available on your desktop, you can right-click to get the context menu, select Properties, and enter the Shortcut Key there. Simply click in the Shortcut Key text field, and press the desired shortcut key.

I've assigned WIN + C to my calculator, and WIN + V to my volume control.