I have a screen that is extensively using Html5 drag and drop, and it works well except for the scrolling behavior while dragging. The screen will scroll when you drag to the edge of the window, but that does not work that well. Now, the users would not mind if they could simply use the arrow-up/down or page-up/down keys to scroll but this does not work apparently! Using old school drag/drop techniques (jquery.ui.draggable
for instance), you do not have this problem, it is only when using the draggable="true"
method.
I was thinking that I could maybe catch the events and provide this behavior myself. So I did a little test, and bound event handlers to window.keydown
and window.keyup
and guess what: none of the browsers I tested fire any key events while dragging.
$(window).keyup(function() {
$('#log').append('<div>key up</div>');
});
$(window).keydown(function() {
$('#log').append('<div>key down</div>');
});
$(window).keypress(function() {
$('#log').append('<div>key press</div>');
});
Fiddle: press a key, then start dragging the span element, and while dragging try pressing a key again (you might have to click the "results" pane first so it has focus)
https://jsfiddle.net/Davy78/xkddhzts/2/
This is silly, I am not able to provide this simple feature request to the users. Does anyone know of any workarounds?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…