Is it possible to scroll content with key up/down?

  • Hi Team,

    This is about running Onsen UI powered web application on computer browser.

    We use scroller class to enable content scrolling. It’s working fine as far as we scroll content using mouse. But it doesn’t scroll content with keyboard up/down keys. If it’s possible, kindly let me know what needs to be enabled.


  • @CNaik You would need an event listener for keydown and you would listen for the following key presses:

    down = 40
    up = 38

    In your callback function, you would manipulate the scroll object: Here is one example:

    $(".someInput").on("keyup", function(e) {
        if (e.which == 40) {
        } else if (e.which == 38) {
        //scroll to element:
        $(".wrapper .inner_div").scrollTop(0);//set to top
        $(".wrapper .inner_div").scrollTop($('.element-hover:first').offset().top-$(".wrapper .inner_div").height());//then set equal to the position of the selected element minus the height of scrolling div

    This came from:


    Here is the Onsen Team discussing something similar here:

  • @munsterlander thank you for detailed answer.

    I was looking if anything is built into Onsen UI. Will work in this direction.


Log in to reply