This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).keydown(function (event) { | |
//UP | |
if (event.which == 38) { | |
event.preventDefault(); | |
$("#bodyBox").animate({ scrollTop: $("#bodyBox").scrollTop() - 100 }, 'fast'); | |
} | |
//DOWN | |
if (event.which == 40) { | |
event.preventDefault(); | |
$("#bodyBox").animate({ scrollTop: $("#bodyBox").scrollTop() + 100 }, 'fast'); | |
} | |
}); |
This uses the JQuery animate() function attached to the element that contains the scroll bar.
You then provide to the scrollTop porpery the current position of the scroll bar plus or minus a value you want to move it by.
No comments:
Post a Comment