Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

& hotkey not disappearing on runtime

Tags:

c#

winforms

The "&" hotkey does not appear on runtime for winforms. I know there was a similar question about this. However this solution is not satisfactory since I want the hotkey to appear instant without changing any desktop setting. My question is there any way to create a hotkey command inside the code without changing any computer Desktop setting?

enter image description here

like image 460
Ali Çarıkçıoğlu Avatar asked Mar 24 '23 05:03

Ali Çarıkçıoğlu


1 Answers

Keyboard accelerators/mnemonics (the things you get by prefixing one of the letters in a control's caption with the ampersand &) still work, regardless of whether they are underlined in the UI or not.

The underlining was just removed by default in Windows XP to remove visual clutter. You can turn it back on in the Control Panel (the exact procedure varies according to the version of Windows), but that's something the user should do, not the application. (For the programmer's convenience, as your screenshot shows, they're always shown in the VS designer.)

Besides, as soon as the user presses the Alt key to use one of the keyboard accelerators, the underlines will show back up for their convenience. But you don't even need this if you know the accelerator key and just press it.

The point is that you should always create keyboard accelerators for your controls for accessibility reasons. They will just work, regardless of settings. Whether they get used for not is up to the user.

like image 80
Cody Gray Avatar answered Apr 06 '23 10:04

Cody Gray