From 50529d2e4a9e1846a87cd6c65cbb98a4af015365 Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Thu, 21 Sep 2023 13:39:07 +0200 Subject: [PATCH] Allows a (experimental) parameter when starting application to handle the keydown event at bubbling phase --- packages/application/src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/application/src/index.ts b/packages/application/src/index.ts index c0f50948e..eeff4ed28 100644 --- a/packages/application/src/index.ts +++ b/packages/application/src/index.ts @@ -506,6 +506,8 @@ export class Application { // Mark the application as started; this._started = true; + this._bubblingKeydown = options.bubblingKeydown || false; + // Parse the host ID for attaching the shell. const hostID = options.hostID || ''; @@ -606,8 +608,11 @@ export class Application { * A subclass may reimplement this method as needed. */ protected addEventListeners(): void { + if (this._bubblingKeydown) { + console.log('The keydown events are handled during bubbling phase'); + } document.addEventListener('contextmenu', this); - document.addEventListener('keydown', this, true); + document.addEventListener('keydown', this, !this._bubblingKeydown); window.addEventListener('resize', this); } @@ -663,6 +668,7 @@ export class Application { private _plugins = new Map(); private _services = new Map, string>(); private _started = false; + private _bubblingKeydown = false; } /** @@ -715,6 +721,8 @@ export namespace Application { * This will override `startPlugins` and any `autoStart` plugins. */ ignorePlugins?: string[]; + + bubblingKeydown?: boolean; } }