Class: KeyboardInfo in Category Windows : System Information from Total Visual SourceBook

Manage keyboard settings such as caps lock and num lock states, with support for 32 and 64-bit API calls using VBA and VB6.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the CKeyboardInfo class.
Alt Property Get the status of the Alt key on the keyboard. This property does not distinguish between left and right keys. To determine which Alt key is pressed, see the LAlt, and RAlt properties.
BlinkTime Property Get the blink time of the caret.
CapsLock Property Get the CapsLock toggle state.
Control Property Get the status of the Control key on the keyboard. This property does not distinguish between left and right keys. To determine which Control key is pressed, see the LControl, and RControl properties.
FunctionKeys Property Get the count of function keys available.
KeyboardType Property Get the type of keyboard.
LAlt Property Get the status of the left Alt key on the keyboard.
LControl Property Get the status of the left Control key on the keyboard.
LShift Property Get the status of the left Shift key on the keyboard.
NumLock Property Get the NumLock toggle state.
RAlt Property Get the status of the right Alt key on the keyboard.
RControl Property Get the status of the right Control key on the keyboard.
RepeatDelay Property Get the keyboard repeat delay value.
RepeatSpeed Property Get the keyboard repeat speed. The values 0 through 31 are valid for this property. The value 0 indicates a repeat speed of about 30 characters per second. The number of characters per second decreases linearly to the value 31, which indicates about 2.5 characters per second. The actual repeat rate is hardware dependent, and may vary by as much as 20%.
RShift Property Get the status of the right Shift key on the keyboard.
ScrollLock Property Get the status of the ScrollLock toggle.
Shift Property Get the status of the Shift key on the keyboard. This property does not distinguish between left and right keys.
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings.
SetKeyState Private Set the toggle state of a key.
' Example of CKeyboardInfo
'
' To use this example, create a new module and paste this code into it.
' Then run the procedure by putting the cursor in the procedure and pressing:
'    F5 to run it, or
'    F8 to step through it line-by-line (see the Debug menu for more options)

Private Sub Example_CKeyboardInfo()
  ' Comments: Example of using the CKeyboardInfo class to get keyboard information, in VB6 and VBA with 32 and 64 bit Windows API calls.
  '           Run this procedure and see the information in the Immediate Window.

  Dim clsKeyboardInfo As CKeyboardInfo

  Set clsKeyboardInfo = New CKeyboardInfo

  ' Print the value of each property
  Debug.Print "Alt Key pressed: " & clsKeyboardInfo.Alt
  Debug.Print "Caret blink time = " & clsKeyboardInfo.BlinkTime
  Debug.Print "Caps Lock on: " & clsKeyboardInfo.CapsLock
  Debug.Print "Control Key pressed: " & clsKeyboardInfo.Control
  Debug.Print "Number of function keys: " & clsKeyboardInfo.FunctionKeys

  Select Case clsKeyboardInfo.KeyboardType
    Case kybIBM83Key
      Debug.Print "Keyboard: IBM 83 Key"
    Case kybICO102Key
      Debug.Print "Keyboard: Olivetti (ICO) 102 Key"
    Case kybIBM84KEY
      Debug.Print "Keyboard: IBM 84 Key"
    Case kybIBM101Or102Key
      Debug.Print "Keyboard: IBM 101 or 102 Key"
    Case kybNokia1050
      Debug.Print "Keyboard: Nokia 1050"
    Case kybNokia9140
      Debug.Print "Keyboard: Nokia 9140"
    Case kybJapanese
      Debug.Print "Keyboard: Japanese"
    Case Else
      Debug.Print "Keyboard: Unknown"
  End Select

  Debug.Print "Left Alt Key pressed: " & clsKeyboardInfo.LAlt
  Debug.Print "Left Control Key pressed: " & clsKeyboardInfo.LControl
  Debug.Print "Left Shift Key pressed: " & clsKeyboardInfo.LShift
  Debug.Print "NumLock on: " & clsKeyboardInfo.NumLock
  Debug.Print "Right Alt Key pressed: " & clsKeyboardInfo.RAlt
  Debug.Print "Right Control pressed: " & clsKeyboardInfo.RControl

  Select Case clsKeyboardInfo.RepeatDelay
    Case kybDelay250ms
      Debug.Print "Repeat delay = 250ms"
    Case kybDelay500ms
      Debug.Print "Repeat delay = 500ms"
    Case kybDelay750ms
      Debug.Print "Repeat delay = 750ms"
    Case kybDelay1000ms
      Debug.Print "Repeat delay = 1000ms"
  End Select

  Debug.Print "Repeat Speed = " & clsKeyboardInfo.RepeatSpeed
  Debug.Print "Right Shift pressed: " & clsKeyboardInfo.RShift
  Debug.Print "Scroll lock on: " & clsKeyboardInfo.ScrollLock
  Debug.Print "Shift Key pressed: " & clsKeyboardInfo.Shift
End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS