Skip to content

Commit 5f5978d

Browse files
Nakshatra SharmaNakshatra Sharma
authored andcommitted
Add copy and paste shortcuts to trackpad toolbar
1 parent 0cbf82f commit 5f5978d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/components/Trackpad/ControlBar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ interface ControlBarProps {
1010
onRightClick: () => void;
1111
onKeyboardToggle: () => void;
1212
onModifierToggle: () => void;
13+
onCopy: () => void;
14+
onPaste: () => void;
1315
}
1416

1517
export const ControlBar: React.FC<ControlBarProps> = ({
@@ -21,6 +23,8 @@ export const ControlBar: React.FC<ControlBarProps> = ({
2123
onRightClick,
2224
onKeyboardToggle,
2325
onModifierToggle,
26+
onCopy,
27+
onPaste,
2428
}) => {
2529
const handleInteraction = (e: React.PointerEvent, action: () => void) => {
2630
e.preventDefault();
@@ -62,11 +66,13 @@ export const ControlBar: React.FC<ControlBarProps> = ({
6266
</button>
6367
<button
6468
className="btn btn-sm btn-outline"
69+
onPointerDown={(e) => handleInteraction(e, onCopy)}
6570
>
6671
Copy
6772
</button>
6873
<button
6974
className="btn btn-sm btn-outline"
75+
onPointerDown={(e) => handleInteraction(e, onPaste)}
7076
>
7177
Paste
7278
</button>
@@ -98,4 +104,4 @@ export const ControlBar: React.FC<ControlBarProps> = ({
98104
</button>
99105
</div>
100106
);
101-
};
107+
};

src/routes/trackpad.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ function TrackpadPage() {
153153
}
154154
};
155155

156+
const getCopyCombo = () => {
157+
return ["control", "c"];
158+
};
159+
160+
const getPasteCombo = () => {
161+
return ["control", "v"];
162+
};
163+
156164
return (
157165
<div
158166
className="flex flex-col h-full overflow-hidden"
@@ -177,6 +185,8 @@ function TrackpadPage() {
177185
onRightClick={() => handleClick('right')}
178186
onKeyboardToggle={focusInput}
179187
onModifierToggle={handleModifierState}
188+
onCopy={() => sendCombo(getCopyCombo())}
189+
onPaste={() => sendCombo(getPasteCombo())}
180190
/>
181191

182192
{/* Extra Keys */}

0 commit comments

Comments
 (0)