public class KeyEventArgs : EventArgs
Arguments for key press events

Constructors

KeyEventArgs

#
public KeyEventArgs(Keys keyData, KeyEventType keyEventType, char? keyChar = null)
Initializes a new instance of the KeyPressEventArgs class for a character key press
keyData (Keys)Key and modifiers that were pressed
keyEventType (KeyEventType)Type of key event
keyChar (char? = null)Character equivalent

Properties

Alt

#
public bool Alt { get; }
Gets whether the alt key was pressed/released for the event

Application

#
public bool Application { get; }
Gets whether the application key was pressed/released for the event

Control

#
public bool Control { get; }
Gets whether the control key was pressed/released for the event

Handled

#
public bool Handled { get; set; }
Gets or sets a value indicating that this event was handled by user code
Remarks: If you pass true for this, typically the key press will not be passed to the control for event processing. This also allows controls to handle key combinations that would otherwise be handled as a shortcut in the menu or toolbar items.

IsChar

#
public bool IsChar { get; }
Gets a value indicating that the key press corresponds to a character input value

KeyChar

#
public char KeyChar { get; }
Gets the key character corresponding to the key press (if IsChar is true)

KeyEventType

#
public KeyEventType KeyEventType { get; }
Gets the type of the key event.

Modifiers

#
public Keys Modifiers { get; }
Gets the modifier keys that were pressed for this event

Shift

#
public bool Shift { get; }
Gets whether the shift key was pressed/released for the event

Methods

IsKeyDown

#
public bool IsKeyDown(Keys key, Keys? modifier = null)
Determines whether the specified key and modifier was pressed
key (Keys)Key to test if it was pressed
modifier (Keys? = null)Modifier of the key, or null to allow any modifiers
true the key with modifier was pressed; otherwise, false.

IsKeyUp

#
public bool IsKeyUp(Keys key, Keys? modifier = null)
Determines whether the specified key and modifier was released
key (Keys)Key to test if it was released
modifier (Keys? = null)Modifier of the key, or null to allow any modifiers
true the key with modifier was released; otherwise, false.