C#:在一个文本框的keydown事件,你如何检测当前按下修饰键+?

问题描述:

C#:在一个文本框的keydown事件,你如何检测当前按下修饰符+键

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'm not sure if and what I'm doing wrong.

    private void txtShortcut_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Modifiers == (Keys.Alt || Keys.Control || Keys.Shift))
        {
            lbLogger.Items.Add(e.Modifiers.ToString() + " + " +
                "show non-modifier key being pressed here");
        }
    }



1)我将如何检查是否E包含任何修改钥匙?

1) How would I check if e contains any modifier keys?

根据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");
        }
    }