- A key code such as System.Windows.Forms.Keys.F1 (the F1 key) or System.Windows.Forms.Keys.Home (the HOME key) in Visual Basic .NET).
- An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of Shift is 6.
Although the KeyDown events can apply to most keys, it is most often used for:
- Extended character keys such as function keys.
- Navigation keys.
- Combinations of keys with standard keyboard modifiers.
- Distinguishing between the numeric keypad and regular number keys.
KeyDown is not invoked for the TAB key.
KeyDown interpret the uppercase and lowercase of each character by means of two arguments: KeyCode, which indicates the physical key (thus returning A and a as the same key) and Shift, which indicates the state of shift+key and therefore returns either A or a.
If you need to test for the Shift argument, you can use the AgEShiftValues constants which define the bits within the argument. The constants act as bit masks that you can use to test for any combination of keys.
In VB.NET the KeyDown event is shown as "xxxxxxxx_KeyDownEvent" in the IDE.
|[Visual Basic .NET]||Copy Code|