Share via


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

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

See Also

Reference

Shape Class

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)

Introduction to the Line and Shape Controls (Visual Studio)