From 8a43ed691df3081d422acfa77bc65784e6ad4a96 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Thu, 2 Jan 2020 14:10:32 -0800 Subject: [PATCH] Handle escape keybinding (#49) --- src/index.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index e5156e1f..11988969 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -374,10 +374,14 @@ class App extends React.Component<{}, AppState> { }; private onKeyDown = (event: KeyboardEvent) => { - if ( - event.key === "Backspace" && - (event.target as HTMLElement).nodeName !== "INPUT" - ) { + if ((event.target as HTMLElement).nodeName === "INPUT") { + return; + } + + if (event.key === "Escape") { + clearSelection(); + drawScene(); + } else if (event.key === "Backspace") { deleteSelectedElements(); drawScene(); event.preventDefault();