Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Determine If CapsLock is On in Visual Basic

The My.Computer.Keyboard object can be used to determine the current state of the keyboard, including such things as whether NUM LOCK or CAPS LOCK is on.

To determine if CAPS LOCK is on

  • To determine whether or not CAPS LOCK is on, use the My.Computer.Keyboard.CapsLock property. The following code displays a message about the state of the CAPS LOCK.

    
    If My.Computer.Keyboard.CapsLock Then
        MsgBox("CAPS LOCK is on")
    Else
        MsgBox("CAPS LOCK is off")
    End If
    
    
    

Community Additions

ADD
Show:
© 2015 Microsoft