Keyboard.IsKeyDown(Key) Metoda

Definice

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

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

truepokud key je ve stavu mimo provoz, v opačném případě . false

Příklady

Následující příklad ukazuje, jak pomocí IsKeyDown metody určit stav určitého klíče. Klíč Return se předá IsKeyDown metodě. Pokud metoda vrátí true, pozadí objektu Button se změní.

// 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ů určitého klíče.

Platí pro

Viz také