I am working on a C# WinForm application in Visual Studio 2008. I have added keyboard shortcuts to some of the buttons, which triggers a button click (CTRL + R, CTRL B and so on…), by overriding ProcessCmdKey.
When the user press and hold the CTRL key I want to show a hint, tooltip or something next to the button with the shortcut text (“CTRL + R”) so the user can see which buttons that has a shortcut and what the combination is.
Does anyone have any other suggestion on how to solve this issue?
I solved this by creating a WPF control that looks similar to a standard tooltip (small box with a label). I then did an override on ProcessCmdKey and OnKeyUp on my form to listen to CTRL key down and key up.
When the user presses and holds down the CTRL key I loop through all my controls that has a shortcut and creates a WPF control on top of that control. For each WPF control I set the corresponding shortcut text. When the CTRL key is released I remove all WPF controls in OnKeyUp.