I need to send send keyboard shortcuts from Windows (i.e. ALT + A) to the render engine (javascript) to trigger some javascript functions.
In javascript I create a new event of the type "KeyboardEvent" with the key information from CEF/C++ and dispatch it to the event listeners (https://developer.mozilla.org/en-US/doc ... boardEvent).
The issue I'm facing is that in javascript, the utilization of traditional key codes like "65" for the keyboard key "A" is deprecated (https://developer.mozilla.org/en-US/doc ... nt/keyCode).
Instead now each key has a string representation. For example the key "A" has the code "KeyA". The code for the key "1" is "Digit1". I'm using this tool to look them up: https://keyjs.dev.
To make it work I have to manually map the virtual key codes I get from Windows API (65 for "A", 49 for "1", etc.) to their corresponding string representation ("KeyA", "Digit1").
Example:
- Code: Select all
switch (vkCode) // <-- virtual key codes from windows WM_KEYDOWN and WM_KEYUP events
{
case 49:
case VK_NUMPAD1:
key = "1";
code = "Digit1";
break;
case 65:
key = "A";
code = "KeyA";
break;
...
}
I was wondering if CEF has any built-in functionality to "translate" theses values automatically?