我需要同时捕获多个键,例如“Shift+Insert”,我如何使用 System.Windows.Input.KeyEventArgs 使用它。我写了一些代码,但它不起作用:
private void Grid1KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Shift && e.Key == System.Windows.Input.Key.Insert)
{
//do something
}
}
谁能帮帮我?
注意:在 silverlight 项目中,您不能使用“System.Windows.Forms”。
请您参考如下方法:
宁愿尝试类似的东西
if (e.Shift && e.Key == System.Windows.Input.Key.Insert)
{
//do something
}
A KeyEventArgs, which specifies the key the user pressed and whether any modifier keys (CTRL, ALT, and SHIFT) were pressed at the same time, is passed with each KeyDown or KeyUp event.
您还可以查看 KeyEventArgs.Modifiers Property
Gets the modifier flags for a KeyDown or KeyUp event. The flags indicate which combination of CTRL, SHIFT, and ALT keys was pressed.
