TIP: Application Wide Hotkey

Need a keyboard shortcut that works anywhere in your app? Add an item to the menubar and then make the item invisible. Add an event handler for that menuitem. Want the hotkey to work only in a specific window or control? Just add an event handler there.

EditMyMenuItemName.Visible = false

You could capture keys in a keydown event but I find there’s some oddities, such as in Windows you don’t receive some keys such as CTRL \ or SHIFT CTRL T

You now have a nice shortcut for something.

[quote=17865:@Stephen Dodd]Need a keyboard shortcut that works anywhere in your app? Add an item to the menubar and then make the item invisible. Add an event handler for that menuitem. Want the hotkey to work only in a specific window or control? Just add an event handler there.

EditMyMenuItemName.Visible = false

You could capture keys in a keydown event but I find there’s some oddities, such as in Windows you don’t receive some keys such as CTRL \ or SHIFT CTRL T

You now have a nice shortcut for something.[/quote]

This sounds more like a bug to me…

Why would it be a bug? “Visible” is a documented property of MenuItem. The documentation does state, however, that the property is not supported under Windows.

Yes, I just realized this is not supported on Windows so this may not be an ideal solution.

Any ideas for a good way to capture cross-platform hot keys?