From 434bacf1852731dc811d41cc6a64cd0dc9656802 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 8 Aug 2021 17:54:53 +0200 Subject: [PATCH] fixed hotkey race condition --- tabby-core/src/services/hotkeys.service.ts | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tabby-core/src/services/hotkeys.service.ts b/tabby-core/src/services/hotkeys.service.ts index 91c2be0f..1237fa95 100644 --- a/tabby-core/src/services/hotkeys.service.ts +++ b/tabby-core/src/services/hotkeys.service.ts @@ -72,20 +72,21 @@ export class HotkeysService { @Inject(HotkeyProvider) private hotkeyProviders: HotkeyProvider[], hostApp: HostAppService, ) { - const events = ['keydown', 'keyup'] - events.forEach(eventType => { - document.addEventListener(eventType, (nativeEvent: KeyboardEvent) => { - this._keyEvent.next(nativeEvent) - this.pushKeyEvent(eventType, nativeEvent) - if (hostApp.platform === Platform.Web && this.matchActiveHotkey(true) !== null) { - nativeEvent.preventDefault() - nativeEvent.stopPropagation() - } - }) - }) this.config.ready$.toPromise().then(async () => { const hotkeys = await this.getHotkeyDescriptions() this.hotkeyDescriptions = hotkeys + const events = ['keydown', 'keyup'] + + events.forEach(eventType => { + document.addEventListener(eventType, (nativeEvent: KeyboardEvent) => { + this._keyEvent.next(nativeEvent) + this.pushKeyEvent(eventType, nativeEvent) + if (hostApp.platform === Platform.Web && this.matchActiveHotkey(true) !== null) { + nativeEvent.preventDefault() + nativeEvent.stopPropagation() + } + }) + }) }) // deprecated