Home | What's New | Articles | Code Downloads | Tool Box | Links | Code Snippets  


Getting the Keyboard's type

This code will return the keyboard's type, sub-type and number of function keys

' Place in General Declarations 
Private Declare Function GetKeyboardType Lib "user32" (ByVal nTypeFlag As Long) As Long

The code below will displays the keyboards type, subtype and number of function keys in a messagebox.

Select Case GetKeyboardType(0) '0 Keyboard type
    Case 0
        MsgBox Err.LastDllError
    Case 1
        MsgBox "IBM PC/XT or compatible (83-key) keyboard. 10 function keys"
    Case 2
        MsgBox "Olivetti ""ICO"" (102-key) keyboard. 12 (sometimes 18) function keys"
    Case 3
        MsgBox "IBM PC/AT (84-key) or similar keyboard. 10 function keys"
    Case 4
        MsgBox "IBM enhanced (101- or 102-key) keyboard. 12 function keys"
    Case 5
        MsgBox "Nokia 1050 and similar keyboards. 10  function keys"
    Case 6
        MsgBox "Nokia 9140 and similar keyboards. 24 function keys"
    Case 7
        MsgBox "Japanese keyboard. Number of function keys Hardware dependent and specified by the OEM"
End Select
MsgBox "Keyboard subtype:" & GetKeyboardType(1)
MsgBox "Number of function keys: " & GetKeyboardType(2)