Fix alt for menus inside of webviews (#116830)

Fixes #104329

This fixes two things:

- Keyup events from webviews were not dispatched back to the main window. We usually listen on keydown but the menubar listeners needs both keydown and keyup

- Instead of listening on document.body for keypress events, we need to listen on window
This commit is contained in:
Matt Bierner
2021-02-18 19:05:47 -08:00
committed by GitHub
parent 096e5555b6
commit 094777f392
3 changed files with 25 additions and 5 deletions

View File

@@ -1475,7 +1475,7 @@ export class ModifierKeyEmitter extends Emitter<IModifierKeyStatus> {
metaKey: false
};
this._subscriptions.add(domEvent(document.body, 'keydown', true)(e => {
this._subscriptions.add(domEvent(window, 'keydown', true)(e => {
const event = new StandardKeyboardEvent(e);
// If Alt-key keydown event is repeated, ignore it #112347
@@ -1509,7 +1509,7 @@ export class ModifierKeyEmitter extends Emitter<IModifierKeyStatus> {
}
}));
this._subscriptions.add(domEvent(document.body, 'keyup', true)(e => {
this._subscriptions.add(domEvent(window, 'keyup', true)(e => {
if (!e.altKey && this._keyStatus.altKey) {
this._keyStatus.lastKeyReleased = 'alt';
} else if (!e.ctrlKey && this._keyStatus.ctrlKey) {