如何确定button点击期间何时按下控制键

如何确定在C#Windows程序中单击button期间何时按下控制键? 我想要一个动作发生Ctrl / Click和一个不同的点击。

Solutions Collecting From Web of "如何确定button点击期间何时按下控制键"

还有一点点:

private void button1_Click ( object sender, EventArgs e ) { if( (ModifierKeys & Keys.Control) == Keys.Control ) { ControlClickMethod(); } else { ClickMethod(); } } private void ControlClickMethod() { MessageBox.Show( "Control is pressed" ); } private void ClickMethod() { MessageBox.Show ( "Control is not pressed" ); } 

假设WinForms,使用Control.ModifierKeys,例如:

 private void button1_Click(object sender, EventArgs e) { MessageBox.Show(Control.ModifierKeys.ToString()); } 

假设WPF,使用Keyboard.Modifiers,例如:

 private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show(Keyboard.Modifiers.ToString()); }