次の方法で共有


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 メソッドは、指定したキーがダウンしているかどうかを返します。

適用対象

こちらもご覧ください