react-dnd-mouse-backend
react-dnd-mouse-backend copied to clipboard
Escape key to cancel drag?
Is it possible to cause the drag the cancel by hitting the escape key? While the HTML 5 backend will cancel the drag on escape, the mouse back end drag is not effected.
Though I donʻt see how that where that might have been implemented explicitly on HTML5, I was looking at the TouchBackend. It has a enableKeyboardEvents property.
When set, it adds a keyboard listener that calls the following on escape.
handleCancelOnEscape (e) {
if (e.key === 'Escape' && this.monitor.isDragging()){
this._mouseClientOffset = {};
this.uninstallSourceNodeRemovalObserver();
this.actions.endDrag();
}
}
Would something like this be needed to handle escape in the mouse back end?
Thanks.