Explorar el Código

Handle escape keybinding (#49)

Christopher Chedeau hace 5 años
padre
commit
8a43ed691d
Se han modificado 1 ficheros con 8 adiciones y 4 borrados
  1. 8 4
      src/index.tsx

+ 8 - 4
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();