Skip to content

Commit

Permalink
chore: Add support for additional delete hotkey (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
belkhoujaons authored Oct 8, 2024
1 parent 0f5aef1 commit 1092265
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/common/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export class Hotkey {
static readonly INTERACT = new Hotkey('i', 'Interact');
static readonly INSERT_DIV = new Hotkey('r', 'Insert Div');
static readonly INSERT_TEXT = new Hotkey('t', 'Insert Text');
static readonly DELETE = new Hotkey('backspace', 'Delete Div');
static readonly BACKSPACE = new Hotkey('backspace', 'Delete Div');
static readonly DELETE = new Hotkey('delete', 'Delete Div');

// private to disallow creating other instances of this type
private constructor(
Expand Down
4 changes: 3 additions & 1 deletion app/src/routes/editor/Canvas/HotkeysArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const HotkeysArea = ({ children, scale, setScale }: HotkeysAreaProps) => {
useHotkeys(Hotkey.UNDO.command, () => editorEngine.action.undo());
useHotkeys(Hotkey.REDO.command, () => editorEngine.action.redo());
useHotkeys('enter', () => editorEngine.textEditSelectedElement());
useHotkeys(Hotkey.DELETE.command, () => editorEngine.deleteSelectedElement());
useHotkeys([Hotkey.BACKSPACE.command, Hotkey.DELETE.command], () =>
editorEngine.deleteSelectedElement(),
);

return <>{children}</>;
};
Expand Down

0 comments on commit 1092265

Please sign in to comment.