JS Keyboard Nav

  • Started
  • Last post
  • 1 Response
  • sisu

    This is killing me. If you can offer some insight, I would appreciate it.

    Using JQuery, Javascript: The desired effect is that when user hits arrow keys up or down, page is scrolled (animated) up or down 300px. It works fine, except in FF, where it kills keyboard, i.e. Command-N, Command-R no longer work.

    $(document).keydown(function(e){
    if(e.which == 38){ $('html, body').animate({scrollTop: $(window).scrollTop() - 300});}
    else if(e.which == 40){ $('html, body').animate({scrollTop: $(window).scrollTop() + 300});}
    return false;
    });

    Example Link: http://www.sisuhome.com/qbn/indeā€¦

  • sisu0

    I've figured this out. Here's the code that works if anyone is interested:

    $(document).keydown(function(e){
    if(e.which == 38){ $('html, body').animate({scrollTop: $(window).scrollTop() - 300}); return false;}
    else if(e.which == 40){ $('html, body').animate({scrollTop: $(window).scrollTop() + 300}); return false;}
    });