Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8904343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:06:23+00:00 2026-06-15T02:06:23+00:00

Disable arrow key scrolling in users browser Zeta was given correct answer for how

  • 0

Disable arrow key scrolling in users browser
Zeta was given correct answer for how to disable the arrow keys.

I need to re-enable arrow key navigation once its disabled.

$('main navigation').has('drop down').bind('keyup', function (e) {
    if (e.keyCode == 40) {hover(e,$(this));} //Down Arrow Key press, how mega menu
    if (e.keyCode == 38) {unhover(e);} //Up Arrow Key Press, hide mega menu
    if (e.keyCode == 9) {checkTab();} //check if tab pressed
}

var checkTab = function (){
        // i check, if tab focus to the main menu anchor
    if($('main navigation').is(':focus')){
        var keys = [];
        window.addEventListener("keydown",
            function(e){
                keys[e.keyCode] = true;
                switch(e.keyCode){
                    case 37: case 39: case 38:  case 40: // Arrow keys
                    case 32: e.preventDefault(); break; // Space
                    default: break; // do not block other keys
                }
            },
        false);
        window.addEventListener('keyup',
            function(e){
                keys[e.keyCode] = false;
            },
        false);             
        console.log('focused')
    }
    else {
        console.log('f out')    
    }                   
}

this works fine, but as I have bind window.event to disable. once disabled I cant enable. Need help in this point.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:06:24+00:00Added an answer on June 15, 2026 at 2:06 am

    Use another variable to determine whether you should currently block the arrow keys:

    var useArrowKeysToScroll = false;
    
    /* ... */
    function(e){
        keys[e.keyCode] = true;
        if(!useArrowKeysToScroll && 
               ((e.keyCode >= 37 && e.keyCode <= 40) || 
                 e.keyCode == 32)){
            e.preventDefault();
        }
        /* handle other keys etc... */
    }, /* ... */
    

    If useArrowKeysToScroll is false it the arrow keys and space bars won’t result in scrolling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to disable the navigation on press of UP and Down arrow keys
Can I somehow disable ListView items navigation through keyboard (arrow keys), and leave navigation
i need to disable the arrow keys in a flowplayer.org scrollable i have a
Possible Duplicate: How to disable browser or element scrollbar, but allow scrolling with wheel
How do you disable the animation that occurs when you use the arrow keys
I am using Ubuntu 10.04 and Firfox 3.6.3 . The tab key, arrow keys
I have a key listener assigned to the arrow keys to navigate a slideshow.
i am new to iphone. i want to disable Back(left arrow button) and Forward(right
I'm trying to disable the hotkeys for left and right arrow on Fancybox 2.
Currently, I'm trying to learn VIM and disabled the arrow keys for all modes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.