Show correct meta key on Linux/macOS in hotkeys modal

This commit is contained in:
Rūdolfs Ošiņš
2024-02-13 13:53:58 +00:00
parent c3626ea5ae
commit b5977588ae
3 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -220,7 +220,7 @@
</label>
or pasting them.
{/if}
Markdown supported. Press {utils.isMac() ? "⌘" : "ctrl"}↵ to submit.
Markdown supported. Press {utils.modifierKey()}↵ to submit.
</div>
{/if}
<div class="buttons">
+9 -3
View File
@@ -204,14 +204,20 @@ export function scrollIntoView(id: string, options?: ScrollIntoViewOptions) {
}
export function isMac() {
// Precaution in case navigator.platform is not available.
if (navigator.platform) {
return navigator.platform.includes("Mac");
if (
(navigator.platform && navigator.platform.includes("Mac")) ||
navigator.userAgent.includes("OS X")
) {
return true;
} else {
return false;
}
}
export function modifierKey() {
return isMac() ? "⌘" : "ctrl";
}
// Check whether the given path has a markdown file extension.
export function isMarkdownPath(path: string): boolean {
return /\.(md|mkd|markdown)$/i.test(path);
+3 -1
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import { modifierKey } from "@app/lib/utils";
import Icon from "@app/components/Icon.svelte";
import IconSmall from "@app/components/IconSmall.svelte";
import KeyHint from "@app/components/KeyHint.svelte";
@@ -39,7 +41,7 @@
<div class="pair">
<span>Post comment</span>
<div class="keys">
<KeyHint>⌘</KeyHint> +
<KeyHint>{modifierKey()}</KeyHint> +
<KeyHint>⏎</KeyHint>
</div>
</div>