KeyEventArgs.IsDown 屬性

定義

取得值,這個值指出事件參考的按鍵是否為已按下的狀態。

public:
 property bool IsDown { bool get(); };
public bool IsDown { get; }
member this.IsDown : bool
Public ReadOnly Property IsDown As Boolean

屬性值

如果按鍵為已按下狀態,則為 true,否則為 false

範例

下列範例會藉由取得 屬性的狀態IsDown,檢查與 實例KeyEventArgs相關聯的索引鍵是否關閉。

// e is an instance of KeyEventArgs.
// btnIsDown is a Button.
if (e.IsDown)
{
    btnIsDown.Background = Brushes.Red;
}
' e is an instance of KeyEventArgs.
' btnIsDown is a Button.
If e.IsDown Then
    btnIsDown.Background = Brushes.Red

備註

類別 Keyboard 也會提供鍵盤上按鍵狀態的相關信息。 例如, IsKeyDown 方法會傳回指定的索引鍵是否關閉。

適用於

另請參閱