I have a page with a scrollable element. My problem is that I want the up/down arrows to scroll this element even if it does not currently have focus.
I'm trying to just trigger a keydown with the same event when any keydown event is detected outside the target element.
$(document).keydown(function(e) {
if ($(e.target).hasClass('box')) {
return;
}
$('.box').trigger('keydown', e);
})
See this JS fiddle: https://jsfiddle.net/4tx6aqrr/2
This is not working. Is what I want to do possible?