Skip to content

Commit 04dde4b

Browse files
committed
fix: hotkey display platform-specific symbols
- Fix formatHotkey to accept platform parameter instead of using React hook - Update HotkeyInput to properly pass platform context to all key display functions - Ensure Mac shows ⌘⌥⇧ symbols while other platforms show Ctrl/Alt/Shift - Fix space key to display as 'Space' word instead of empty - Update all formatHotkey callers to pass platform parameter correctly
1 parent 344fcb8 commit 04dde4b

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

src/components/HotkeyInput.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Check, Edit2, X } from "lucide-react";
22
import React, { useCallback, useEffect, useState } from "react";
33
import { Button } from "./ui/button";
44
import { formatHotkey } from "@/lib/hotkey-utils";
5+
import { usePlatform } from "@/contexts/PlatformContext";
56
import {
67
normalizeShortcutKeys,
78
validateKeyCombinationWithRules,
@@ -24,6 +25,7 @@ export const HotkeyInput = React.memo(function HotkeyInput({
2425
placeholder,
2526
validationRules = ValidationPresets.standard()
2627
}: HotkeyInputProps) {
28+
const { isMac } = usePlatform();
2729
const [mode, setMode] = useState<"display" | "edit">("display");
2830
const [keys, setKeys] = useState<Set<string>>(new Set());
2931
const [pendingHotkey, setPendingHotkey] = useState("");
@@ -105,10 +107,10 @@ export const HotkeyInput = React.memo(function HotkeyInput({
105107
// Update current keys display
106108
const displayKeys = [];
107109
if (modifiers.includes("CommandOrControl"))
108-
displayKeys.push(formatKeyForDisplay("CommandOrControl"));
109-
if (modifiers.includes("Alt")) displayKeys.push(formatKeyForDisplay("Alt"));
110-
if (modifiers.includes("Shift")) displayKeys.push(formatKeyForDisplay("Shift"));
111-
displayKeys.push(...regularKeys.map(k => formatKeyForDisplay(k)));
110+
displayKeys.push(formatKeyForDisplay("CommandOrControl", isMac));
111+
if (modifiers.includes("Alt")) displayKeys.push(formatKeyForDisplay("Alt", isMac));
112+
if (modifiers.includes("Shift")) displayKeys.push(formatKeyForDisplay("Shift", isMac));
113+
displayKeys.push(...regularKeys.map(k => formatKeyForDisplay(k, isMac)));
112114
setCurrentKeysDisplay(displayKeys.join(" + "));
113115

114116
// Validate with rules
@@ -225,7 +227,7 @@ export const HotkeyInput = React.memo(function HotkeyInput({
225227
<div className="flex items-center gap-2">
226228
<div className="flex-1 flex items-center">
227229
{value ? (
228-
formatHotkey(value)
230+
formatHotkey(value, isMac)
229231
) : (
230232
<span className="text-muted-foreground">{placeholder || "No hotkey set"}</span>
231233
)}
@@ -249,7 +251,7 @@ export const HotkeyInput = React.memo(function HotkeyInput({
249251
<div className="flex items-center gap-2">
250252
<div className="flex-1 flex items-center">
251253
{pendingHotkey ? (
252-
formatHotkey(pendingHotkey)
254+
formatHotkey(pendingHotkey, isMac)
253255
) : currentKeysDisplay ? (
254256
<span className="text-foreground">{currentKeysDisplay}</span>
255257
) : (

src/components/onboarding/OnboardingDesktop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export const OnboardingDesktop = function OnboardingDesktop({
537537
<div className="space-y-2">
538538
<h1 className="text-3xl font-bold">You're all set!</h1>
539539
<p className="text-muted-foreground">
540-
Press {formatHotkey(hotkey)} to start recording
540+
Press {formatHotkey(hotkey, isMacOS)} to start recording
541541
</p>
542542
</div>
543543

src/components/sections/RecentRecordings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ScrollArea } from "@/components/ui/scroll-area";
22
import { formatHotkey } from "@/lib/hotkey-utils";
33
import { TranscriptionHistory } from "@/types";
44
import { useCanRecord, useCanAutoInsert } from "@/contexts/ReadinessContext";
5+
import { isMacOS } from "@/lib/platform";
56
import { invoke } from "@tauri-apps/api/core";
67
import { ask } from "@tauri-apps/plugin-dialog";
78
import { AlertCircle, Mic, Trash2 } from "lucide-react";
@@ -129,7 +130,7 @@ export function RecentRecordings({ history, hotkey = "Cmd+Shift+Space", onHistor
129130
<p className="text-sm text-muted-foreground">No recordings yet</p>
130131
{canAutoInsert ? (
131132
<p className="text-xs text-muted-foreground/70 mt-2">
132-
Press {formatHotkey(hotkey)} to start recording
133+
Press {formatHotkey(hotkey, isMacOS)} to start recording
133134
</p>
134135
) : (
135136
<p className="text-xs text-amber-600 mt-2">

src/lib/hotkey-utils.tsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { cn } from '@/lib/utils';
2-
import { usePlatform } from '@/contexts/PlatformContext';
32

43
/**
54
* Formats a hotkey string into styled keyboard keys
65
* e.g., "cmd+shift+space" -> styled keyboard keys
76
*/
8-
export function formatHotkey(hotkey: string): React.ReactNode {
9-
const { isMac } = usePlatform();
7+
export function formatHotkey(hotkey: string, isMac: boolean = false): React.ReactNode {
108

119
if (!hotkey) return null;
1210

@@ -28,25 +26,34 @@ export function formatHotkey(hotkey: string): React.ReactNode {
2826

2927
// Map common key names to display names
3028
const keyDisplayMap: Record<string, string> = {
31-
'cmd': isMac ? 'cmd' : 'ctrl',
32-
'ctrl': 'ctrl',
33-
'shift': 'shift',
34-
'alt': 'alt',
35-
'space': 'space',
36-
'enter': 'enter',
37-
'tab': 'tab',
38-
'escape': 'esc',
39-
'esc': 'esc',
40-
'delete': 'del',
41-
'backspace': '⌫',
29+
'cmd': isMac ? '⌘' : 'Ctrl',
30+
'ctrl': 'Ctrl',
31+
'commandorcontrol': isMac ? '⌘' : 'Ctrl',
32+
'command': isMac ? '⌘' : 'Ctrl',
33+
'shift': isMac ? '⇧' : 'Shift',
34+
'alt': isMac ? '⌥' : 'Alt',
35+
'option': isMac ? '⌥' : 'Alt',
36+
'meta': isMac ? '⌘' : 'Ctrl',
37+
'space': 'Space',
38+
'enter': isMac ? '⏎' : 'Enter',
39+
'return': isMac ? '⏎' : 'Enter',
40+
'tab': isMac ? '⇥' : 'Tab',
41+
'escape': 'Esc',
42+
'esc': 'Esc',
43+
'delete': isMac ? '⌦' : 'Del',
44+
'backspace': isMac ? '⌫' : 'Backspace',
4245
'up': '↑',
4346
'down': '↓',
4447
'left': '←',
4548
'right': '→',
46-
'pageup': 'PgUp',
47-
'pagedown': 'PgDn',
48-
'home': 'Home',
49-
'end': 'End',
49+
'arrowup': '↑',
50+
'arrowdown': '↓',
51+
'arrowleft': '←',
52+
'arrowright': '→',
53+
'pageup': isMac ? '⇞' : 'PgUp',
54+
'pagedown': isMac ? '⇟' : 'PgDn',
55+
'home': isMac ? '⇱' : 'Home',
56+
'end': isMac ? '⇲' : 'End',
5057
'f1': 'F1',
5158
'f2': 'F2',
5259
'f3': 'F3',

0 commit comments

Comments
 (0)