is there a way to detect all the key pressed in keydown event of the form? For example im currently pressing CRTL + Alt + A can i get all the keys in keydown event? i need to get all the keys to create my own hot keys in my currently developing application
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you want to find which keys are pressed, you could do this,
if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) // Is Alt key pressed
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.A))
{
MessageBox.Show("Key pressed");
}
}
回答2:
You can check for all keys in event arguments
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.Control && e.KeyCode == Keys.A)
{
//do something
}
}