Hook Setup:
- Code: Select all
SetWindowsHookExA(WH_KEYBOARD_LL, KeyManager::LowLevelKeyboardProc, m_hinstance, 0);
LRESULT CALLBACK KeyManager::LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
LOG(INFO) << "LowLevelKeyboardProc: nCode: " << nCode << ", wParam: " << wParam << ", lParam: " << lParam;
// Logic to block windows key and other processing...
}
This approach has been working seamlessly until we encountered web pages that make a call to getUserMedia:
- Code: Select all
navigator.mediaDevices.getUserMedia({ audio: true });
Upon invoking getUserMedia, we observe that the LowLevelKeyboardProc callback is not triggered as long as CEF retains focus. However, when the focus is shifted away from the CEF window, the callback works as expected.
I've been considering alternatives like OnPreKeyEvent in CEF, but I'm not fully versed with its implementation, especially for trapping specific keys like the Windows key.
Environment:
Windows Versions: 10/11
Observed in CEF Versions: 5672, 5845 (There might be more affected versions)
Any insights or workarounds to address this interaction would be greatly appreciated.