Shape.IsKeyLocked Method
Determines whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK key is in effect.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
Public Shared Function IsKeyLocked ( _
keyVal As Keys _
) As Boolean
public static bool IsKeyLocked(
Keys keyVal
)
public:
static bool IsKeyLocked(
Keys keyVal
)
static member IsKeyLocked :
keyVal:Keys -> bool
public static function IsKeyLocked(
keyVal : Keys
) : boolean
Parameters
- keyVal
Type: System.Windows.Forms.Keys
The CAPS LOCK, NUM LOCK, or SCROLL LOCK member of the Keys enumeration.
Return Value
Type: System.Boolean
true if the specified key or keys are in effect; otherwise, false.
Exceptions
Exception | Condition |
---|---|
NotSupportedException | The keyVal parameter refers to a key other than the CAPS LOCK, NUM LOCK, or SCROLL LOCK key. |
Remarks
Use the IsKeyLocked property to determine whether the CAPS LOCK, NUM LOCK, or SCROLL LOCK keys are on, individually or in combination.
Examples
The following example displays a message box indicating whether the specified key (the CAPS LOCK key in this case) is in effect.
Private Sub GetCapsLocked(ByVal shape As Shape)
' You can test for the CAPS LOCK, NUM LOCK, OR SCROLL LOCK key
' by changing the value of Keys.
If shape.IsKeyLocked(Keys.CapsLock) Then
MsgBox("The Caps Lock key is ON.")
Else
MsgBox("The Caps Lock key is OFF.")
End If
End Sub
private void GetCapsLocked(Shape shape)
{
// You can test for the CAPS LOCK, NUM LOCK, OR SCROLL LOCK key
// by changing the value of Keys.
if (Shape.IsKeyLocked(Keys.CapsLock))
{
MessageBox.Show("The Caps Lock key is ON.");
}
else
{
MessageBox.Show("The Caps Lock key is OFF.");
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualBasic.PowerPacks Namespace
Other Resources
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)