I want to use the Input.dispatchKeyEvent API defined at https://chromedevtools.github.io/devtools-protocol/tot/Input/
An example invocation of this API is:
const eventArgs = {
'modifiers': 0,
'text': 'e',
'unmodifiedText': 'e',
'key': 'e',
'code': 'KeyE',
'windowsVirtualKeyCode': 69,
'type': 'keyDown'
};
Input.dispatchKeyEvent(eventArgs);
I want to dynamically generate these eventArgs from a keyboard shortcut label such as:
Ctrl + Alt + e
Has anyone come across a similar conversion function?
- The modifiers could be easily parsed to create the bitmap I suppose.
- I'm not too sure on the differences between text, unmodifiedText, key, and code.
- The windowsVirtualKeyCode I think can be derived from 'e'.charCodeAt(0).
I might be able to come up with some trial-and-error tables, but if someone's seen/done this before that could help a lot!