Keyboard.Modifiers プロパティ

定義

現在押されている ModifierKeys のセットを取得します。

public:
 static property System::Windows::Input::ModifierKeys Modifiers { System::Windows::Input::ModifierKeys get(); };
public static System.Windows.Input.ModifierKeys Modifiers { get; }
static member Modifiers : System.Windows.Input.ModifierKeys
Public Shared ReadOnly Property Modifiers As ModifierKeys

プロパティ値

ModifierKeys 値のビットごとの組み合わせ。

次の例では、ビット AND 比較を使用して、修飾子キーが Control 押されているかどうかを判断します。

if ((Keyboard.Modifiers & ModifierKeys.Control) > 0)
{
    button1.Background = Brushes.Red;
}
else
{
    button1.Background = Brushes.Blue;
}
If (Keyboard.Modifiers And ModifierKeys.Control) > 0 Then
    button1.Background = Brushes.Red
Else
    button1.Background = Brushes.Blue
End If

注釈

ModifierKeys はビット フィールド列挙であるため、複数の修飾子キーを同時に押す可能性があります。 ビット演算を使用して、押された修飾子キーの正確なセットを決定します。

適用対象