I just run the SimpleOSRBrowser and I got this information in the debug log.
Pressing F3 :
Code: Select all
[0531/095730.151:INFO:CEF4Delphi(1)] kind: KEYEVENT_RAWKEYDOWN, modifiers: $00000100, windows_key_code: $00000072, native_key_code: $003D0001, is_system_key: False, character: $0000, unmodified_character: $0000, focus_on_editable_field: False
[0531/095730.217:INFO:CEF4Delphi(1)] kind: KEYEVENT_KEYUP, modifiers: $00000100, windows_key_code: $00000072, native_key_code: $C03D0001, is_system_key: False, character: $0000, unmodified_character: $0000, focus_on_editable_field: False
Pressing shift+F5 :
Code: Select all
[0531/100217.454:INFO:CEF4Delphi(1)] kind: KEYEVENT_RAWKEYDOWN, modifiers: $00000502, windows_key_code: $00000010, native_key_code: $002A0001, is_system_key: False, character: $0000, unmodified_character: $0000, focus_on_editable_field: False
[0531/100217.644:INFO:CEF4Delphi(1)] kind: KEYEVENT_RAWKEYDOWN, modifiers: $00000102, windows_key_code: $00000074, native_key_code: $003F0001, is_system_key: False, character: $0000, unmodified_character: $0000, focus_on_editable_field: False
[0531/100217.718:INFO:CEF4Delphi(1)] kind: KEYEVENT_KEYUP, modifiers: $00000102, windows_key_code: $00000074, native_key_code: $C03F0001, is_system_key: False, character: $0000, unmodified_character: $0000, focus_on_editable_field: False
[0531/100217.859:INFO:CEF4Delphi(1)] kind: KEYEVENT_KEYUP, modifiers: $00000100, windows_key_code: $00000010, native_key_code: $C02A0001, is_system_key: False, character: $0000, unmodified_character: $0000, focus_on_editable_field: False
The code in WebView4Delphi to simulate those key presses is this :
Code: Select all
function TWVBrowserBase.KeyboardShortcutSearch : boolean;
begin
Result := SimulateKeyEvent(ketRawKeyDown, $100, VK_F3, integer($003D0001)) and
SimulateKeyEvent(ketKeyUp, $100, VK_F3, integer($C03D0001));
end;
function TWVBrowserBase.KeyboardShortcutRefreshIgnoreCache : boolean;
begin
Result := SimulateKeyEvent(ketRawKeyDown, $502, VK_Shift, integer($002A0001)) and
SimulateKeyEvent(ketRawKeyDown, $102, VK_F5, integer($003F0001)) and
SimulateKeyEvent(ketKeyUp, $102, VK_F5, integer($C03F0001)) and
SimulateKeyEvent(ketKeyUp, $100, VK_Shift, integer($C02A0001));
end;
The code comments for those two functions might have a clue why we see different information :
This key information was logged using a Spanish keyboard. It might not work with different keyboard layouts.
The GetCefKeyboardModifiers function in uCEFMiscFunctions checks what keys are pressed in that moment and it will fail if you put a breakpoint in it because your hand will move away from the keyboard while debugging.
The official sample application handles keyboard messages here :
https://github.com/chromiumembedded/cef/blob/8e79307a622dc513f084b4ac0b78caed08e0c1c0/tests/cefclient/browser/osr_window_win.cc#L531
https://github.com/chromiumembedded/cef/blob/8e79307a622dc513f084b4ac0b78caed08e0c1c0/tests/cefclient/browser/osr_window_win.cc#L786
The original GetCefKeyboardModifiers function is here :
https://github.com/chromiumembedded/cef/blob/8e79307a622dc513f084b4ac0b78caed08e0c1c0/tests/shared/browser/util_win.cc#L82
The modifier values you see in WebView4Dedlphi are calculated with the windows message parameters and the detected pressed keys like this :
- $100 = EVENTFLAG_NUM_LOCK_ON
- $502 = EVENTFLAG_NUM_LOCK_ON or EVENTFLAG_SHIFT_DOWN or EVENTFLAG_IS_LEFT
- $102 = EVENTFLAG_NUM_LOCK_ON or EVENTFLAG_SHIFT_DOWN