Control.ModifierKeys プロパティ

定義

どの修飾子キー (Shift キー、Ctrl キーおよび Alt キー) が押された状態であるかを示す値を取得します。

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

プロパティ値

Keys

Keys 値のビットごとの組み合わせ。 既定値は、None です。

次のコード例では、Ctrl キーを押しながらボタンをクリックすると、ボタンが非表示になります。 この例では、Button.button1 Form

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

こちらもご覧ください