How to capture a pressed function key and then perform an action on a Windows application (822492)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
SUMMARYThis article describes
how to capture a pressed function key and then perform an action on a Microsoft
Windows application.
Function keys should
be captured in the KeyDown event of the control. The event handler receives an argument of type KeyEventArgs. The KeyValue property of KeyEventArgs provides information about the key that you pressed. You can compare
the KeyValue property with the Keys enumeration
class constraints.
The Keys enumeration class specifies all the key codes and all the key
modifiers.
The Keys enumeration class contains constants that you can use to process
the keyboard input. Keys are identified by the key values. A key value
is made up of a key code and a set of modifiers that are combined in a single
integer value.
The four left digits of a
key value contain the key code for the modifier keys (the SHIFT key, the CTRL
key, and the ALT key), and the four right digits of a key value contain
modifier bits for the modifier keys.
The modifier keys cannot be
trapped in the KeyDown event of the control.
Therefore, you should
use the bitwise AND operator with the ModifierKeys property together with a value of the Keys enumeration class to determine what modifier key is in a pressed state. ModifierKeys is a shared member of the Control class.
The Control.ModifierKeys property receives a value that indicates what modifier
key is in a
pressed state. REFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web site:
| Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
|---|
| Keywords: | kbvs2005applies kbvs2005swept kbHOWTOmaster kbhowto kbWindowsForms kbForms KB822492 kbAudDeveloper |
|---|
|