Add before-input-event event for webContents (fixes #7586)
Embedding arbitrary web content is problematic when it comes to keyboard shortcuts because: * Web content can steal app shortcuts (see e.g. brave/browser-laptop#4408) * Blocked web content (e.g. a focused <webview> performing expensive computation) will also prevent app shortcuts from firing immediately The new before-input-event event can be used to overcome these issues by always handle certain keyboard events in the main process. Note that this requires electron/brightray#261 to compile.
This commit is contained in:
parent
3290c6b335
commit
a3b65ad481
4 changed files with 170 additions and 0 deletions
|
@ -232,6 +232,26 @@ Emitted when a plugin process has crashed.
|
|||
|
||||
Emitted when `webContents` is destroyed.
|
||||
|
||||
#### Event: 'before-input-event'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `input` Object - Input properties
|
||||
* `type` String - Either `keyUp` or `keyDown`
|
||||
* `key` String - Equivalent to [KeyboardEvent.key](keyboardevent)
|
||||
* `isAutoRepeat` Boolean - Equivalent to [KeyboardEvent.repeat](keyboardevent)
|
||||
* `shift` Boolean - Equivalent to [KeyboardEvent.shiftKey](keyboardevent)
|
||||
* `control` Boolean - Equivalent to [KeyboardEvent.controlKey](keyboardevent)
|
||||
* `alt` Boolean - Equivalent to [KeyboardEvent.altKey](keyboardevent)
|
||||
* `meta` Boolean - Equivalent to [KeyboardEvent.metaKey](keyboardevent)
|
||||
|
||||
Emitted before dispatching the `keydown` and `keyup` events in the page.
|
||||
Calling `event.preventDefault` will prevent the page `keydown`/`keyup` events
|
||||
from being dispatched.
|
||||
|
||||
[keyboardevent]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
|
||||
|
||||
#### Event: 'devtools-opened'
|
||||
|
||||
Emitted when DevTools is opened.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue