I successfully enabled this alert to show whenever I scrolled down with my mouse in the <div>
$('#divID').bind('mousewheel DOMMouseScroll', function (event) {
if (event.originalEvent.wheelDelta < 0 || event.originalEvent.detail > 0)
{
alert('scroll down with scroll');
}
});
What is the equivalent .bind method I can use to alert whenever I scrolled down with my down arrow key in the <div>
My attempt is (but doesn't work):
$('#section1').bind('onkeydown', function (event) {
if (event.keyCode == 40) {
alert('scroll down with arrow key');
}
});
I'd highly appreciate any help.
I've checked out a solution from: JavaScript KeyCode Values are "undefined" in Internet Explorer 8
- However with this, I can't seem to have this alert happen for a specific <div>
, I don't want this effect lingering throughout the whole document.
I am also using .bind()
and not any other method, it's because when I get to another <div>
I want to .unbind()
the previous, because in another <div>
I want to do a new .bind()