Control::IsKeyLocked Method (Keys)
Determines whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK key is in effect.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- keyVal
-
Type:
System.Windows.Forms::Keys
The CAPS LOCK, NUM LOCK, or SCROLL LOCK member of the Keys enumeration.
Return Value
Type: System::Booleantrue if the specified key or keys are in effect; otherwise, false.
| Exception | Condition |
|---|---|
| NotSupportedException | The keyVal parameter refers to a key other than the CAPS LOCK, NUM LOCK, or SCROLL LOCK key. |
Use the IsKeyLocked property to determine whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK keys are on, whether individually or in combination.
The following code example displays a message box indicating whether the specified key (the Caps Lock key in this case) is in effect.
#using <System.dll> #using <System.Drawing.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Windows::Forms; int main() { if (Control::IsKeyLocked( Keys::CapsLock )) { MessageBox::Show( "The Caps Lock key is ON." ); } else { MessageBox::Show( "The Caps Lock key is OFF." ); } }
Available since 2.0