Keyboard State Gadget

Hi, I have a wireless keyboard that does not have status lights for num, caps or scroll lock,

I want to write a gadget to show this however i cannot find any information on calling the API from javascript.

If anyone has any ideas or examples on this i would be greatful.

Ian Paskin



Answer this question

Keyboard State Gadget

  • Robet

    I don't believe you'll be able to get the keyboard state just using JavaScript.

    The only approach I can think of offhand is to write a COM wrapper that calls GetKeyState in user32.dll. You can use that COM object from your gadget script, then.



  • Larrybird02744

    As Scott states, you'll need a COM. Here's the code you'll need (VB).
    I haven't tried it, but I believe it returns 1 for NumLock/CapsLock/ShiftLock if they're on.


    Private Declare Function GetKeyState Lib "user32" (ByVal key As Long) As Integer

    Public Function KeyState(keyCode As Long) As Integer
    KeyState = GetKeyState(keyCode)
    End Function

  • Peter Kalev

    Thanks guy's i will give it a go,


  • Keyboard State Gadget