C#: In the keydown event of a textbox, how do you detect currently pressed modifiers + keys?
I did the following, but I\'m not too familiar with these operators so I
The documentation says it is a bitwise combination, but you're doing a logical OR.
Try:
if (e.Modifiers & (Keys.Alt | Keys.Control | Keys.Shift))
{
lbLogger.Items.Add(e.Modifiers.ToString() + " + " +
"show non-modifier key being pressed here");
}
And I think you can get the actual key with e.KeyCode.ToString().
according to msdn linkt
private void txtShortcut_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt || e.Control || e.Shift))
{
lbLogger.Items.Add(e.ToString() + " + " +
"show non-modifier key being pressed here");
}
}