Handle escape keybinding (#49)

This commit is contained in:
Christopher Chedeau 2020-01-02 14:10:32 -08:00 committed by GitHub
parent 0d75b78374
commit 8a43ed691d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();