JSFiddle - React, Tailwind, and code Playground
by TJ VanToll
HTML
<ul id='sortable'>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
JavaScript
var sorting = false;
$(document).keydown(function( event ) {
if (event.keyCode === $.ui.keyCode.ESCAPE) {
if (sorting) {
$('#sortable').sortable('cancel');
}
}
});
$('#sortable').sortable({
revert: 150,
start: function() { sorting = true; },
stop: function() {
$('#sortable').sortable('cancel');
sorting = false;
}
});