In a Windows native DLL running inside an application, I’ve installed a keyboard hook with the following callback procedure:
LRESULT CALLBACK onKeyHookEvent_(int code, WPARAM keyCode, LPARAM keyFlags)
{
if (code < 0)
return CallNextHookEx(NULL, code, keyCode, keyFlags);
if (keyFlags & KF_UP)
doSomething();
return 0;
}
But the procedure never gets a keyFlags with the KF_UP bit(s) set. My fear is that the main application is somehow “swallowing” the release events before they get to my hook.
Is there anything else I must do to make a keyboard hook sensitive to key releases?
It appears that the KF_UP mask must be shifted into the high position of a 32-bit word. The correct code:
The weird thing is, I see no mention of this in the MSDN documentation on KeyboardProc callbacks.