KeyEventArgs.IsDown KeyEventArgs.IsDown KeyEventArgs.IsDown KeyEventArgs.IsDown Property

Definition

Gets a value that indicates whether the key referenced by the event is in the down state.

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

Property Value

true if the key is down; otherwise, false.

Examples

The following example checks whether the key associated with an instance of KeyEventArgs is down by obtaining the state of the IsDown property.

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

Remarks

The Keyboard class also provides information about the state of the keys on the keyboard. For instance, the IsKeyDown method returns whether a specified key is down.

Applies to

See also