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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:22:24+00:00 2026-06-04T04:22:24+00:00

Is there a way to stop a webpage from refreshing completely when the enter

  • 0

Is there a way to stop a webpage from refreshing completely when the enter button is pressed in a input text element?

I’m looking to create a search field that I can get the text from when enter is pressed to filter objects and only display the ones that contain text from the search field.

I’ve tried the following to try and catch the enter button but it does not work.

function setupSearchField() {
    document.getElementById("searchField").onKeyDown = function(event) {
        var holder;
        if (window.event) {
            holder = window.event.keyCode;
        } else {
            holder = event.which;
        }
        keyPressed(holder);
    }
}

function keyPressed(key) {
    if (key == 13) {
        event.cancelBubble = true;
        return false;
    }
}
  • 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-04T04:22:25+00:00Added an answer on June 4, 2026 at 4:22 am

    If the input element is inside a form, and that form is not actually being submitted to the server, remove the form.

    The reason your code doesn’t work is becaue the onkeydown event should be in lowercase, and you aren’t actually returning something in it (try return keyPressed(holder); – or just move the keyPressed function’s code into setupSearchField, since it seems kind of pointless to me to have it as a separate function).

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

Sidebar

Related Questions

Is there any way to stop the callout from automatically appearing on an embedded
Is there any way to stop IB in XCode 4 from zooming to try
Is there a way to stop Edit>Find in Xcode from searching dynamically as I
Is there a way to stop Microsoft Lync from detecting phone numbers in a
Is there a way to stop the WebBrowser control from causing its parent form
Is there any way to stop the execution EVERY time the app enter in
Is there any way to stop Firefox from submitting a form on a Javascript
Is there a way to stop setTimeout(myfunction(),10000); from counting up when the page isn't
Hello Is there a way to stop TFSBUILD from adding the buildID/BuildName to the
Is there a way to stop Google from indexing a site?

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.