Using .net 2.0 is there a way to obtain the text to display, for example as a menu shortcut, from the System.Windows.Forms.Keys code? The keys can be set by the user, so it could be any key combination. This needs to work in the local language (not just English).
I’ve tried KeysConverter.ConvertToString, but the results seem largely useless. Eg it gives “OemMinus” (for main keyboard -) or “Subtract” (for NumPad -). Outside F1-F12 and A-Z very few of these would be understood by our users. Because the application is specifically intended for people with physical difficulty accessing computers it uses a lot of key combinations as one mode of access, and I need to be able to describe ANY of the keys on the keyboard.
Is there a way to get key names which are actually meaningful to end users?
This type converter was designed to be used by you, not your user. You’ll see it in action when you use the dropdown for the ShortcutKeys property for a menu item. It thus contains key names that might please a programmer, but sure, not a user. That’s why that same control also has the ShortcutKeyDisplayString property, the text that the user actually sees.
You’ll have to make your own.