Skip to content
This repository was archived by the owner on May 3, 2025. It is now read-only.

Commit 3b80ba2

Browse files
authored
Add Windows/Linux support for keyboard shortcuts (#186)
* Add Windows/Linux support for commands * Display correct modifier key based on system
1 parent a6abae6 commit 3b80ba2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/workstation/edit-tab.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { useHotkeys } from "react-hotkeys-hook";
1212
import { useClipboardState } from "utils/hooks/use-clipboard-state";
1313
import { useToneControls } from "utils/hooks/use-tone-controls";
1414

15+
const shortcutKey = navigator.platform.includes("Mac") ? "⌘" : "Ctrl+";
16+
1517
interface EditTabProps {}
1618

1719
const EditTab: React.FC<EditTabProps> = (props: EditTabProps) => {
@@ -26,7 +28,7 @@ const EditTab: React.FC<EditTabProps> = (props: EditTabProps) => {
2628
[]
2729
);
2830

29-
useHotkeys("cmd+d", duplicateSelected, [isPlaying, selectedState]);
31+
useHotkeys("cmd+d, ctrl+d", duplicateSelected, [isPlaying, selectedState]);
3032

3133
return (
3234
<React.Fragment>
@@ -40,7 +42,7 @@ const EditTab: React.FC<EditTabProps> = (props: EditTabProps) => {
4042
closePopover,
4143
duplicateSelected
4244
)}
43-
secondaryText={"⌘D" as any}>
45+
secondaryText={shortcutKey + "D" as any}>
4446
Duplicate
4547
</Menu.Item>
4648
<Menu.Item

src/components/workstation/file-tab.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { isNotNilOrEmpty } from "utils/core-utils";
1616
import { useHotkeys } from "react-hotkeys-hook";
1717
import { ExportDialog } from "components/workstation/export-dialog";
1818

19+
const shortcutKey = navigator.platform.includes("Mac") ? "⌘" : "Ctrl+";
20+
1921
interface FileTabProps {}
2022

2123
enum ConfirmationAction {
@@ -129,7 +131,7 @@ const FileTab: React.FC<FileTabProps> = (props: FileTabProps) => {
129131
);
130132

131133
useHotkeys(
132-
"cmd+s",
134+
"cmd+s, ctrl+s",
133135
(event) => {
134136
event.preventDefault();
135137
handleSave()();
@@ -205,7 +207,7 @@ const FileTab: React.FC<FileTabProps> = (props: FileTabProps) => {
205207
</Menu.Item>
206208
<Menu.Item
207209
onClick={handleSave(closePopover)}
208-
secondaryText={"⌘S" as any}>
210+
secondaryText={shortcutKey + "S" as any}>
209211
Save
210212
</Menu.Item>
211213
<Menu.Item onClick={handleExportClick(closePopover)}>

0 commit comments

Comments
 (0)