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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:02:26+00:00 2026-06-01T16:02:26+00:00

I need this for a chat box. When the user press enter, I want

  • 0

I need this for a chat box. When the user press enter, I want to trigger a callback (to send the message and clean the input field)

So far I got this, but the typing becomes slow:

$('#chat_input').keydown(function(event) {
  if(event.keyCode == '13') {
    // do something
  }
});

How would you optimize this?

UPDATE: It’s not a huge slow down, but I can feel it. I’m pretty sure this code is the responsible. I have always had this problem, so I thought it was about time to find a different way if possible.

  • 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-01T16:02:28+00:00Added an answer on June 1, 2026 at 4:02 pm

    No, your code are not the guilty one here. Since you are building a chat system, you must be running other scripts as well. But here is another way to look into the problem.

    Make a mini form

    <form name="chatline" ... >
       <input type="text" />
       <input type="submit" />
    </form>
    

    Then catch the submit event of the form, which will be triggered on enter automatically by the browser

    $("form").submit(function() {
        //there you go, you caught your enter
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a simple chat. When user sends message to server I want to
All I need this for is strcpy(). I want to see whether the first
I want to build a simple web-interface application that can send/receive chat messages to/from
What I want to do is something like this: $(.chat-wrapper).on(click, .chat-wrapper li, function(){ $(this.name).hide();
I am generating messages like this $msg({to: 'user', from: 'me', type: 'chat'}).c(body).t('some data'); that
I want to implement a chat option on website in which any register user
I have an input (at chat) and emoticons. I need to set when some
I need this for some animation effects and i remember there is a window
I need this for calling a C function from Java class (JNI) and I
I need this because the constructor in the superclass is calling a method which

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.