I've integrated the sendInputEvent
method into BrowserView
:
view.webContents.sendInputEvent({type: 'keyDown', keyCode: 'C'})
In the rendering page of BrowserWindow
, I've added:
window.addEventListener('keydown', function(event) {
console.log("App_S-keyDown-event: ", event)
})
This setup functions properly with all keys and arrow keys (up, down).
The problem arises when dealing with MouseWheelInputEvent
:
type string - The type of the event, can be mouseWheel
: https://www.electronjs.org/docs/latest/api/structures/mouse-wheel-input-event
When I include:
SearchWindow.webContents.sendInputEvent({type: 'mouseWheel'})
An error message is generated:
TS2345: Argument of type '{ type: "mouseWheel"; }' is not assignable to parameter of
type 'MouseInputEvent | MouseWheelInputEvent | KeyboardInputEvent'.
Property 'keyCode' is missing in type '{ type: "mouseWheel"; }' but required in type
'KeyboardInputEvent'.
This appears to be a challenge related to using typescript
with electron
.
Additional information:
electron: 19
typescript: ~4.5.4
O.S.: Ubuntu 22.04 Desktop
How can this issue be resolved?