Keyboard.IsKeyDown(Key) Metoda

Definice

Určuje, zda je zadaná klávesa stisknuta.

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

Parametry

key
Key

Zadaný klíč.

Návraty

true je-li key ve stavu dolů; jinak , false.

Příklady

Následující příklad ukazuje, jak použít metodu IsKeyDown k určení stavu konkrétního klíče. Klíč Return se předá IsKeyDown metodě. Pokud metoda vrátí true, pozadí objektu Button je změněno.

// Uses the Keyboard.IsKeyDown to determine if a key is down.
// e is an instance of KeyEventArgs.
if (Keyboard.IsKeyDown(Key.Return))
{
    btnIsDown.Background = Brushes.Red;
}
else
{
    btnIsDown.Background = Brushes.AliceBlue;
}
' Uses the Keyboard.IsKeyDown to determine if a key is down.
' e is an instance of KeyEventArgs.
If Keyboard.IsKeyDown(Key.Return) Then
    btnIsDown.Background = Brushes.Red
Else
    btnIsDown.Background = Brushes.AliceBlue
End If

Poznámky

Metodu GetKeyStates lze použít k určení sady stavů konkrétního klíče.

Platí pro

Viz také