使用C#在Windows窗体应用程序中创建具有多个字符(ALt + DE)的快捷键

时间:2015-10-08 07:46:56

标签: c#

我想使用C#在Windows窗体应用程序中设计一个快捷键框架。例如" Alt + DE" ,使得第二个快捷键选项是多个字符的组合。有没有办法实现这一目标。

1 个答案:

答案 0 :(得分:0)

MSDN:

  

https://support.microsoft.com/en-gb/kb/839201

示例代码:

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Alt && e.KeyCode.ToString() == "F")
    {
        // When the user presses both the 'Alt' key and 'F' key,
        // KeyPreview is set to False, and a message appears.
        // This message is only displayed when KeyPreview is set to True.
        this.KeyPreview = true;
        MessageBox.Show("KeyPreview is True, and this is from the FORM.");
    } 
}