I am using this code to detect whether modifier keys are being held down in the KeyDown event of a text box.
private void txtShortcut_KeyDown(object sender,
If you are using .NET 3, you will want to use the KeysConverter class, which has support for localized names of the modifier keys:
var kc = new KeysConverter();
var result = kc.ConvertToString(e.KeyCode);
Otherwise, you can do it yourself with the ternary operator:
var keys = (e.Shift ? "[Shift]+" : string.Empty)
+ (e.Control ? "[Ctrl]+" : string.Empty)
+ (e.Alt ? "[Alt]+" : string.Empty)
+ e.KeyCode;