言語

Keyboard.IsKeyToggled(Key) メソッド

定義

指定したキーを切り替えるかどうかを決定します。

public:
 static bool IsKeyToggled(System::Windows::Input::Key key);
public static bool IsKeyToggled(System.Windows.Input.Key key);
static member IsKeyToggled : System.Windows.Input.Key -> bool
Public Shared Function IsKeyToggled (key As Key) As Boolean

パラメーター

key
Key

指定したキー。

返品

true keyが切り替えられた状態の場合は。それ以外の場合はfalse

次の例は、 IsKeyToggled メソッドを使用して特定のキーの状態を判断する方法を示しています。 Return キーは、IsKeyToggled メソッドに渡されます。 メソッドが trueを返す場合、 Button の背景が変更されます。

// Uses the Keyboard.IsToggled to determine if a key is toggled.
if (Keyboard.IsKeyToggled(Key.Return))
{
    btnIsToggle.Background = Brushes.Red;
}
else
{
    btnIsToggle.Background = Brushes.AliceBlue;
}
' Uses the Keyboard.IsToggled to determine if a key is toggled.
If Keyboard.IsKeyToggled(Key.Return) Then
    btnIsToggle.Background = Brushes.Red
Else
    btnIsToggle.Background = Brushes.AliceBlue
End If

注釈

GetKeyStates メソッドを使用して、特定のキーの状態のセットを決定できます。

適用対象

こちらもご覧ください