Skip to content

Commit

Permalink
fix keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliodiez committed Aug 21, 2024
1 parent bf83dfd commit 918abab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
21 changes: 0 additions & 21 deletions src/pods/canvas/canvas.pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,6 @@ export const CanvasPod = () => {
updateShapePosition(id, { x, y });
};

/*
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
const isCtrlOrCmdPressed = e.ctrlKey || e.metaKey;
if (isCtrlOrCmdPressed && e.key === 'c' && canCopy) {
copyShapeToClipboard();
}
if (isCtrlOrCmdPressed && e.key === 'v' && canPaste) {
pasteShapeFromClipboard();
}
};
window.addEventListener('keydown', handleKeyDown);
return () => {
window.removeEventListener('keydown', handleKeyDown);
};
}, [selectedShapeId]);
*/

{
/* TODO: add other animation for isDraggerOver */
}
Expand Down
4 changes: 2 additions & 2 deletions src/pods/toolbar/shortcut/shortcut.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export const SHORTCUTS: Shortcut = {
copy: {
description: 'Copy',
id: 'copy-button-shortcut',
targetKey: ['Ctrl', 'C'],
targetKey: ['c'],
targetKeyLabel: 'Ctrl + C',
},
paste: {
description: 'Paste',
id: 'paste-button-shortcut',
targetKey: ['Ctrl', 'V'],
targetKey: ['v'],
targetKeyLabel: 'Ctrl + V',
},
};
6 changes: 4 additions & 2 deletions src/pods/toolbar/shortcut/shortcut.hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export interface ShortcutHookProps {
export const useShortcut = ({ targetKey, callback }: ShortcutHookProps) => {
const handleKeyPress = (event: KeyboardEvent) => {
const isAltKeyPressed = event.getModifierState('Alt');
const isCtrlKeyPressed = event.getModifierState('Control');
//const isCtrlKeyPressed = event.getModifierState('Control');
const isCtrlOrCmdPressed = event.ctrlKey || event.metaKey;

if (
(isWindowsOrLinux() && isAltKeyPressed) ||
(isMacOS() && isCtrlKeyPressed)
(isMacOS() && isCtrlOrCmdPressed)
) {
console.log('event.key', event.key);
if (targetKey.includes(event.key)) {
event.preventDefault();
callback();
Expand Down

0 comments on commit 918abab

Please sign in to comment.