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,
You need to display the right string depending on the bool value. To do things like that in a single statement, use the ? : operator:
txtShortcut.Text = (e.Shift ? "[Shift]" : string.Empty) + (e.Control ? "[Ctrl]" : string.Empty) + ...;
Generally, it's:
? :
It works with any type.