academica
academica

Reputation: 333

GetKeyState function doesn't work with CAPITAL key code

I'm working on my WPF application and use third party screen keyboard in it. Actually, I'm developing from my home computer (under Win10) on developing machine which is Intel NUC (under Win7) via RDP and have a trouble with GetKeyState function. Function always returns that CAPITAL isn't pressed on my developer pc, though it turns on and off indeed. I tried it with wired/wireless keyboard, via RDP or not. At the same time the same code works perfect on my home pc and GetKeyState function returns real CAPS LOCK key state.

The code is

public static bool IsTogglingKeyInEffect(VirtualKeyCode keyCode)
{
    Int16 result = GetKeyState((UInt16)keyCode);
    return (result & 0x01) == 0x01;
}

Please help with an advice, I have no idea what is the matter.

Upvotes: 0

Views: 552

Answers (1)

shreesha
shreesha

Reputation: 1881

You can try below code to check caps lock is on

 if(Console.CapsLock)
        {
           //do something
        }

Upvotes: 1

Related Questions