如果在鼠标左键单击 Ctrl Alt ,我想检查我的表单。有没有办法检查它?
答案 0 :(得分:5)
WPF: 在xaml中向窗口添加事件:
MouseLeftButtonDown="window_MouseLeftButtonDown_1"
或代码背后:
public MainWindow()
{
InitializeComponent();
this.MouseLeftButtonDown += window_MouseLeftButtonDown_1;
}
然后你可以检查回叫中的按键
private void window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt))
{
// ...
}
}
答案 1 :(得分:5)
void window_MouseLeftButtonDown_1(object sender, MouseEventArgs e)
{
if (Control.ModifierKeys == Keys.Control && Control.ModifierKeys == Keys.Alt)
{
//...
}
}