react-dnd-mouse-backend icon indicating copy to clipboard operation
react-dnd-mouse-backend copied to clipboard

Escape key to cancel drag?

Open srgreen00 opened this issue 5 years ago • 0 comments

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.

srgreen00 avatar May 14 '19 20:05 srgreen00