Control.ModifierKeys 屬性

定義

取得表示哪個輔助按鍵 (SHIFT、CTRL 和 ALT) 是處於按下狀態的值。

C#
public static System.Windows.Forms.Keys ModifierKeys { get; }

屬性值

Keys

Keys 值的位元組合。 預設為 None

範例

下列程式碼範例會在按一下按鈕時按下 CTRL 鍵時隱藏按鈕。 此範例要求您在 上具有 Button 具名 button1Form

C#
private void button1_Click(object sender, System.EventArgs e)
{
   /* If the CTRL key is pressed when the 
      * control is clicked, hide the control. */
   if(Control.ModifierKeys == Keys.Control)
   {
      ((Control)sender).Hide();
   }
}

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另請參閱