From a1cd91c0c5fbeb1c8009ceb25dff60780bf2ba4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 14 May 2022 09:24:04 +0200 Subject: [PATCH] Forward keys to trigger quickbar (#587) --- src/main.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.ts b/src/main.ts index 5b76397c6..fdd1b0a0a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -105,6 +105,19 @@ class HacsFrontend extends HacsElement { }) ); + document.body.addEventListener("keydown", (ev: KeyboardEvent) => { + if (ev.key || ev.ctrlKey || ev.shiftKey || ev.metaKey) { + // Ignore if modifier keys are pressed + return; + } + if (["c", "m", "e"].includes(ev.key)) { + // @ts-ignore + fireEvent(mainWindow, "hass-quick-bar-trigger", ev, { + bubbles: false, + }); + } + }); + makeDialogManager(this, this.shadowRoot!); }