I'm dragging divs around. Sometimes, I want to cancel the dragging by hitting the keyboard escape key. This ends the drag (the "dragend" is fired) but I do not seem to be able to figure out how in my "dragend" handler I can distinguish if the drag was successfully completed or cancelled. Is there a way?
Note that I'm not using the automatic copy/move/data transfer mechanism, because I have specific things that happen when dragging objects that are different from simply moving the object around in the DOM. Therefore, the "dropeffect" is always "none" in my case.
More generally, I would very much like to receive "keydown" events during the drag, but they all vanish completely. This is exceptionally annoying since I do want to make a UI that has great keyboard support and one of the features I want is to be able to modify the element during the drag (e.g., imagine a "snapping" functionality that you want to turn on or off during the drag).
I do believe the latter one is impossible, unfortunately. But is at least the former doable?
I think you are intended to determine what happened with respect to the drag through the
dropEffectof thedataTransferobject of the drag event. It it's 'none', it didn't work. Anything else is successful.Firefox has a prefixed prop
mozUserCancelledthat will tell you if it was aborted, but it's not standard.I looked through the Processing model spec and the best mention of the processing of the "escape" key doesn't really differentiate from other aborts: