diff --git a/src/components/video-editor/KeyboardShortcutsHelp.tsx b/src/components/video-editor/KeyboardShortcutsHelp.tsx index b4cd2e4..453c613 100644 --- a/src/components/video-editor/KeyboardShortcutsHelp.tsx +++ b/src/components/video-editor/KeyboardShortcutsHelp.tsx @@ -1,4 +1,5 @@ import { HelpCircle } from "lucide-react"; +import { formatShortcut } from "@/utils/platformUtils"; export function KeyboardShortcutsHelp() { return ( @@ -21,15 +22,15 @@ export function KeyboardShortcutsHelp() {
Delete Selected - ⌘ + D + {formatShortcut(['mod', 'D'])}
Pan Timeline - ⇧ + ⌘ + Scroll + {formatShortcut(['shift', 'mod', 'Scroll'])}
Zoom Timeline - ⌘ + Scroll + {formatShortcut(['mod', 'Scroll'])}
diff --git a/src/components/video-editor/timeline/TimelineEditor.tsx b/src/components/video-editor/timeline/TimelineEditor.tsx index 907081d..d383b79 100644 --- a/src/components/video-editor/timeline/TimelineEditor.tsx +++ b/src/components/video-editor/timeline/TimelineEditor.tsx @@ -18,6 +18,7 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { type AspectRatio, getAspectRatioLabel } from "@/utils/aspectRatioUtils"; +import { formatShortcut } from "@/utils/platformUtils"; const ZOOM_ROW_ID = "row-zoom"; const TRIM_ROW_ID = "row-trim"; diff --git a/src/utils/platformUtils.ts b/src/utils/platformUtils.ts new file mode 100644 index 0000000..4c63b81 --- /dev/null +++ b/src/utils/platformUtils.ts @@ -0,0 +1,35 @@ +/** + * Detects if the current platform is macOS + */ +export const isMac = (): boolean => { + if (typeof navigator === 'undefined') return false; + return /Mac|iPhone|iPad|iPod/.test(navigator.platform); +}; + +/** + * Gets the modifier key symbol based on the platform + */ +export const getModifierKey = (): string => { + return isMac() ? '⌘' : 'Ctrl'; +}; + +/** + * Gets the shift key symbol based on the platform + */ +export const getShiftKey = (): string => { + return isMac() ? '⇧' : 'Shift'; +}; + +/** + * Formats a keyboard shortcut for display based on the platform + * @param keys Array of key combinations (e.g., ['mod', 'D'] or ['shift', 'mod', 'Scroll']) + */ +export const formatShortcut = (keys: string[]): string => { + return keys + .map(key => { + if (key.toLowerCase() === 'mod') return getModifierKey(); + if (key.toLowerCase() === 'shift') return getShiftKey(); + return key; + }) + .join(' + '); +}; \ No newline at end of file