From 40d9926718b3e4f30ca87651a1f22d7f214f29e4 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 10 Apr 2021 13:38:51 +0300 Subject: [PATCH] dashboard: use cmd+s/cmd+f on mac --- dashboard/src/components/dashboard/GuildConfigEditor.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dashboard/src/components/dashboard/GuildConfigEditor.vue b/dashboard/src/components/dashboard/GuildConfigEditor.vue index f620a293..b9448ddc 100644 --- a/dashboard/src/components/dashboard/GuildConfigEditor.vue +++ b/dashboard/src/components/dashboard/GuildConfigEditor.vue @@ -102,14 +102,19 @@ tabSize: 2 }); + const isMac = /mac/i.test(navigator.platform); + const modKeyPressed = (ev: KeyboardEvent) => (isMac ? ev.metaKey : ev.ctrlKey); + const nonModKeyPressed = (ev: KeyboardEvent) => (isMac ? ev.ctrlKey : ev.metaKey); + const shortcutModifierPressed = (ev: KeyboardEvent) => modKeyPressed(ev) && !nonModKeyPressed(ev) && !ev.altKey; + this.shortcutKeydownListener = (ev: KeyboardEvent) => { - if (ev.ctrlKey && !ev.altKey && ev.key === "s") { + if (shortcutModifierPressed(ev) && ev.key === "s") { ev.preventDefault(); this.save(); return; } - if (ev.ctrlKey && !ev.altKey && ev.key === "f") { + if (shortcutModifierPressed(ev) && ev.key === "f") { ev.preventDefault(); this.$refs.aceEditor.editor.execCommand("find"); return;