Redigeeri

Jagamisviis:


Keyboard.IsKeyToggled(Key) Method

Definition

Determines whether the specified key is toggled.

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

Parameters

key
Key

The specified key.

Returns

true if key is in the toggled state; otherwise, false.

Examples

The following example shows how to use the IsKeyToggled method to determine the state of a specific key. The Return key is passed to the IsKeyToggled method. If the method returns true, then the background of a Button is changed.

// 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

Remarks

The GetKeyStates method can be used to determine the set of states of a specific key.

Applies to

See also