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

  • SEARCH
  • Home
  • 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 3234708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:25:23+00:00 2026-05-17T17:25:23+00:00

This is what I want to happen.. When a user hits ‘enter’ a ‘SearchForItems()’

  • 0

This is what I want to happen.. When a user hits ‘enter’ a ‘SearchForItems()’ should trigger. What is happening is another control, with ‘other button’, on the page gets focus returned to it anytime any other element is tabbed out of or after onkeyup.

I am having to force focus on the ‘Search button’ on page load, but after that any time enter is pressed the ‘other button’ is triggered. The ‘other button’ does not have a tab index assigned and is the pages default button.

I’m not sure if I’ve done a good job explaining this. Basically I want to know why focus is being shifted and how I can force the ‘Search button’ to trigger anytime enter is pressed.

this is one entry on my page where I’m trying to force the ‘Search button’ to trigger:

<td><input type="text" onkeydown="CheckForEnterKey(event)" id="AcceptedDate1" maxlength="7"  style="width:121px;" value="<%=DateTime.Now.AddMonths(-3).ToString("MM/yyyy")%>"/>&nbsp;</td>

this is part of my jquery file where i’m also

$('#AcceptedDate1').keypress(function(e) { if (e.keyCode == 13 || e.which == 13) $('#SearchAcceptedLotsButton').click(); });

CheckForEnterKey Function

function CheckForEnterKey(e)
    {
        var keycode;
        if(e.which)
        {
            keycode = e.which;
        }
        else
        {
            keycode = e.keyCode;
        }

        if(keycode == 13)
        {
            $('#SearchAcceptedLotsButton').click();//tried SearchForItems() also
        }
    }

Edit:

I just added this to my page and it appears to work, I added this to the main div thats holding everything together. What I need to do now is figure out where the enter was pressed so the enter is canceled everytime it is pressed within the main portion of my page. Any ideas, there are a lot of elements on my page?

function checkKey(e)
    {
        if(e.keyCode == 13 || e.which == 13)
        {
            e.returnValue = false;
            e.cancel = true;
        }
    }
  • 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-17T17:25:23+00:00Added an answer on May 17, 2026 at 5:25 pm

    this is how I resolved the issue:

    I added this function..

    function checkKey(e)
        {
            if(e.keyCode == 13 || e.which == 13)
            {
                e.returnValue = false;
                e.cancel = true;
                SearchAcceptedLots();
            }
        }
    

    At the top most div containing everything on the page I added this:

    <div id="ItemPanel" onkeydown="checkKey(event)">
    

    this catches every enter that is pressed within the form, canceling the default buttons behavior and calling the desired function.

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

Sidebar

Related Questions

How do I get and print a char from a user? This want do
I am using the wordpress function update_user_meta($user_ID, 'meta_key', $meta); I want this happen only
Here's what I want to have happen: When the user clicks a link in
So I can't seem to completely exit the application, I want this to happen
I want this: http://jqueryui.com/demos/dialog/#modal-message to happend when you click on ClickMe. how to do
I want this url http://www.youtube.com/watch?v=dgNgODPIO0w&feature=rec-HM-fresh+div to be transformed to: http://www.youtube.com/v/dgNgODPIO0w with php.
I want this for some conditional compilation code that will run in all IE's
I want this to be on top... how can I do this and not
I only want this function to run if .toolbar li does not have the
So I only want this JavaScript to be included in the response to the

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.