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 7684525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:02:46+00:00 2026-05-31T19:02:46+00:00

ok… I might be a lazy one to search but it is a bit

  • 0

ok… I might be a lazy one to search but it is a bit annoying that all I can find is

“how can i set scroll down event” when I searched “how do i prevent scroll down”.

in my javascript code, I set event for down arrow key. When I press down arrow

from the browser, the browser not only does an event I set, but also does

scrolling down the page which is not I intended to. So here is my question.

How can I disable scroll down function which occurs when I press down arrow?

any help will be appreciated.

  • 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-05-31T19:02:47+00:00Added an answer on May 31, 2026 at 7:02 pm

    If you want to prevent the vertical scrollbar and any vertical scrolling action by the user, you can use this javascript:

    document.body.style.overflowY = "hidden";​
    

    Or, this can also be set with a CSS rule:

    body {overflow-y: hidden;}
    

    On the other hand, if what you’re trying to do is to prevent the default key handler for the down arrow from doing anything after you process the down array, then you need to call e.preventDefault() like this:

    function myKeyDownHandler(e) {
        // your code here
        e = e || window.event;
        if (e.preventDefault) {
            e.preventDefault();
        } else {
            e.returnValue = false;   // older versions of IE (yuck)
        }
        return false;
    }
    

    A cleaner way if you need to do this in more than one place would be to make your own cross browser function for this:

    function preventDefault(e) {
        e = e || window.event;
        if (e.preventDefault) {
            e.preventDefault();
        } else {
            e.returnValue = false;   // older versions of IE (yuck)
        }
    }
    
    function myKeyDownHandler(e) {
        // your code here
        preventDefault(e);
        return false;
    }
    

    This is one of those perfect examples where a cross-browser framework (jQuery/YUI/etc) saves you time because they’ve already done all this cross-browser work for you.

    Here’s an interesting article on preventDefault and stopPropagation().

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

Sidebar

Related Questions

so I did $subject = 'sakdlfjsalfdjslfad <a href=something/8230>lol is that true?</a> lalalala'; $subject =
CGI.escapeHTML is pretty bad, but CGI.unescapeHTML is completely borked. For example: require 'cgi' CGI.unescapeHTML('&#8230;')
I have an element like this: <span class=tool_tip title=The full title>The ful&#8230;</span> This seems
Why does the Android system throw this Exception? 05-18 12:33:44.169 W/System.err( 8230): java.io.IOException: Is
what about this one: I want to format the currentTime displayed by a videoPlayer
I often read such messages. But what is the reason of the replacement? I
I have this xml <entry id=1008 section=articles> <excerpt><p>&#8230; in Richtung „Aus für Tierversuche. Kosmetik-Fertigprodukte
I see that some rss on xml have strange strings. For example, ... is
I have a form, one of the fields is a select field, with 5
After much research, I have found that Laravel is very nice. I have a

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.