mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Clear active tool on escape
This commit is contained in:
parent
a73e4e28aa
commit
5e558d6847
1 changed files with 10 additions and 3 deletions
|
@ -147,13 +147,20 @@ export class App extends React.Component<{}, AppState> {
|
|||
};
|
||||
|
||||
private onKeyDown = (event: KeyboardEvent) => {
|
||||
if (isInputLike(event.target)) return;
|
||||
|
||||
if (event.key === KEYS.ESCAPE) {
|
||||
clearSelection(elements);
|
||||
this.forceUpdate();
|
||||
console.log('selection')
|
||||
this.setState({ elementType: 'selection' });
|
||||
if (window.document.activeElement instanceof HTMLElement) {
|
||||
window.document.activeElement.blur()
|
||||
}
|
||||
event.preventDefault();
|
||||
} else if (event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE) {
|
||||
return;
|
||||
}
|
||||
if (isInputLike(event.target)) return;
|
||||
|
||||
if (event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE) {
|
||||
this.deleteSelectedElements();
|
||||
event.preventDefault();
|
||||
} else if (isArrowKey(event.key)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue