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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:03:58+00:00 2026-05-17T19:03:58+00:00

I want to be able to either Press the enter key or click the

  • 0

I want to be able to either Press the enter key or click the mouse to submit the info in the inputbox.

Right now when you manually change focus using tab or click with mouse it will submit the info. It is using the jQuery live Click method.
I found this solution for setting focus to a button

Setting focus to a button next to a text box

but I don’t know how to implement that so I can listen using the live click and do either or. A mouse click or the enter button. Any help is appreciated.

example: be able to do this using either the enter button with focus or a mouse click.

$('#theinput').keypress(function(event) { 
  if (event.keyCode == '13') { 
    $('#mybutton').click(); 
    event.preventDefault(); 
  } 
}); 

Problem is I don’t know how to convert that example to also use something like this

$('a.button').live('click',function(){
//do stuff here
)};
  • 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-17T19:03:58+00:00Added an answer on May 17, 2026 at 7:03 pm

    I would do this using a named function:

    $(document).ready(function(){
        var submitter = function() {
           // do something
        };
    
        $('#theinput').keypress(function(event) {
            if (event.keyCode == '13') {
                event.preventDefault(); 
                submitter();
            } 
        });
    
        $('a.button').live('click', submitter);
    });
    

    This uses the same function for both events without triggering another unnecessary event, which would cause performance issues.

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

Sidebar

Related Questions

I've a method that I want to be able to accept either a single
I want the wrapper my_function to be able to receive either a class or
I want to be able to do the following actions with a form submit
I want to be able to bind a single and double click event to
I want to be able to pass either a string literal, 'this is a
I want our users of a web site to be able to either search
I want to be able to select values from either column, where column a
I want to be able to do something along the lines of Press any
I have a function that I want to be able to accept either an
I want to be able to open either a .jpg, .gif or .bmp into

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.