Fix: Quick Bar not launching on windows (#7293)

This commit is contained in:
Donnie 2020-10-13 02:23:18 -07:00 committed by GitHub
parent 5cddb482f1
commit 5de225d5d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,13 +11,15 @@ declare global {
}
}
const isMacOS = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
export default <T extends Constructor<HassElement>>(superClass: T) =>
class extends superClass {
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
document.addEventListener("keydown", (e: KeyboardEvent) => {
if (e.code === "KeyP" && e.metaKey) {
if (this.isOSCtrlKey(e) && e.code === "KeyP") {
e.preventDefault();
const eventParams: QuickBarParams = {};
if (e.shiftKey) {
@ -28,4 +30,8 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>
}
});
}
private isOSCtrlKey(e: KeyboardEvent) {
return isMacOS ? e.metaKey : e.ctrlKey;
}
};