Caps Lock key and Num Lock key

If I press Caps Lock key or Num Lock key
I wish the status bar shows 'Cap' or 'Num'. How can I do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

the onkeydown event (parameter key) sould tell you when it happens.

you just have after to write what you need in the status bar

regards, Marc

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
an example for retrieving CAPS state:

if (GetKeyState(VK_CAPITAL) and $01) <> 0 then
  // caps active
  // caps inactive

u can poll this in a timer event or put it in the keydown event of the form or in a message handling proc.

btw: i could send ya a statusbar component doing just this. post ur email addr; i'll send it ovuh 2 ya.

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

You really have to poll because caps lock could be changed when another app has the focus. Your app would not get a keydown event.

BTW, here is how you can set and set the NUMLOCK state. (This is Microsoft's method. It is a translation of C code from the MSDN).

function GetNumLock: Boolean;
  var KeyState: Integer;
    KeyState := GetKeyState(VK_NUMLOCK);
    Result := KeyState and 1 = 1;

procedure SetNumLock(bState: Boolean);
  var KeyState: TKeyBoardState;
    if (bState and (KeyState[VK_NUMLOCK] and 1 = 0)) or
       ((not bState) and (KeyState[VK_NUMLOCK] and 1 = 1)) then
        // Simulate a key press
          keybd_event( VK_NUMLOCK,
                       KEYEVENTF_EXTENDEDKEY or 0,
                       0 );

        // Simulate a key release
          keybd_event( VK_NUMLOCK,

petershaw8Author Commented:
Thanks all of you.
My email address is
It is very nice if Blackdeath send me your status bar. BTW, Blackdeath: what message handling proc should be?
u can hook a message handling procedure in2 the message chain 4 keyboard events. there u'll get 2 parameters containing all u need bout the pressed key. i've got a sample @home. mayb i remember 2 bring it w/ me 2morrow so i can send it ovuh. it's 2 much trouble here @work 2 gather all i've needed the last time i wrote it. it's not so much the proc itself; it's the parameter evaluation.

the statusbar is on the way...


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.