Share via


Keyboard.IsKeyToggled(Key) Metodo

Definizione

Determina se il tasto specificato è attivato o disattivato.

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

Parametri

key
Key

Chiave specificata.

Restituisce

true se l'oggetto key è nello stato attivato o disattivato; in caso contrario, false.

Esempio

Nell'esempio seguente viene illustrato come usare il IsKeyToggled metodo per determinare lo stato di una chiave specifica. La Return chiave viene passata al IsKeyToggled metodo . Se il metodo restituisce true, lo sfondo di un Button oggetto viene modificato.

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

Commenti

Il GetKeyStates metodo può essere usato per determinare il set di stati di una chiave specifica.

Si applica a

Vedi anche