I have an image that I've set up with jQuery UI to be draggable. This works fine but now I'd like to be able to Shift-drag on the image to draw a box on the image and not have it move. So if the Shift key is held down I don't want to do the drag.
I've tried putting
if(e.shiftKey)return;
at the top of the drag_start, dragging, and drag_stop functions but this doesn't do anything because the drag operation seems to be done internally in jQuery UI and the calls to drag_start, dragging and drag_stop are just courtesy calls to let you know what jQueryUI is currently doing.
Is there a way to disable the drag if the Shift key is held down?
Thanks
(For more information on this see my "answer" farther below with a jsfiddle.)
How about on start_drag
if shift key then return false;
(don't initiate drag)
function box_start_drag(e, ui) {
if(e.shiftKey)
return false;
}
Fiddle
Or to stop dragging any time shift
is held down. Put the return false in the drag
method as Dom suggests in the comments below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With