Shape.IsKeyLocked Method (Keys)

 

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

public static bool IsKeyLocked(
    Keys keyVal
)
public:
static bool IsKeyLocked(
    Keys keyVal
)
static member IsKeyLocked : 
        keyVal:Keys -> bool
Public Shared Function IsKeyLocked (
    keyVal As Keys
) As Boolean

Parameters

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 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.");
    }
}
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

See Also

Shape Class
Microsoft.VisualBasic.PowerPacks Namespace
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)
Introduction to the Line and Shape Controls (Visual Studio)

Return to top