System.Windows.Forms
1.0.5000.0
2.0.0.0
System.EventArgs
System.Runtime.InteropServices.ComVisible(true)
A specifies the character that is composed when the user presses a key. For example, when the user presses SHIFT + K, the property returns an uppercase K.
A event occurs when the user presses a key. Two events that are closely related to the event are and . The event precedes each event when the user presses a key, and a event occurs when the user releases a key. When the user holds down a key, duplicate and events occur each time the character repeats. One event is generated upon release.
With each event, a is passed. A is passed with each and event. A specifies whether any modifier keys (CTRL, SHIFT, or ALT) were pressed along with another key. (This modifier information can also be obtained through the property of the class.)
Set to true to cancel the KeyPress event. This keeps the control from processing the key press.
Some controls will process certain key strokes on . For example, processes the Enter key before is called. In such cases, you cannot cancel the event, and must cancel the key stroke from instead.
For information about the event model, see [<topic://cpconEventsDelegates>].
Provides data for the event.
Constructor
Use the property to get the current state of the modifier keys.
Initializes a new instance of the class.
The ASCII character corresponding to the key the user pressed.
1.0.5000.0
2.0.0.0
Property
System.Boolean
To be added.
If the event is not handled, it will be sent to the operating system for default processing. Set to true to cancel the KeyPress event.
Gets or sets a value indicating whether the event was handled.
1.0.5000.0
2.0.0.0
Property
System.Char
To be added.
Use the property to sample keystrokes at run time and to modify keystrokes under special run-time circumstances. For example, you can use to disable non-numeric keypresses when the user enters a ZIP code, change all alphabetical keypresses to uppercase in a data entry field, or monitor the keyboard or other key input device for specific key combinations.
You can get or set the following keys:
-
a-z, A-Z.
-
CTRL.
-
Punctuation marks.
-
Number keys, both across the top of the keyboard and on the numeric keypad.
-
ENTER.
You cannot get or set the following keys:
-
The TAB key.
-
INSERT and DELETE.
-
HOME.
-
END.
-
PAGE UP and PAGE DOWN.
-
F1-F2.
-
ALT.
-
Arrow keys.
For information about how to detect any of the non-character keys mentioned above, see the class.
-
Gets or sets the character corresponding to the key pressed.
1.0.5000.0
2.0.0.0