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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:53:06+00:00 2026-06-12T17:53:06+00:00

So I got a textfield I use for a small chat program, and I

  • 0

So I got a textfield I use for a small chat program, and I let the chat send whatever is in a textfield by capturing the keydown event and sending the content of the textfield whenever enter is pressed. Problem is: Enter for some reason places a whitespace at the place where the user was last writing, so if the user clicks somewhere into the middle of the text in the textfield and then presses enter the message gets sent with a whitespace in the middle of it, which is very annoying…
Any solutions?

  • 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-12T17:53:07+00:00Added an answer on June 12, 2026 at 5:53 pm

    Use of preventDefault on enter will not allow any space in text area.
    HTML:

    ​<form action='www.google.com'>
    <textarea id =textareaId>
    
    </textarea>
    </form>​
    

    JS:

    var ta = document.getElementById("textareaId");
    ta.onkeydown = function(e){
    
        if(e.keyCode == 13){
            e.preventDefault();
            document.forms[0].submit();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to catch a valueDidChange-Event for a Textfield? oO I've got
I have got a performance problem about TextField.htmlText +=msg .And I know that TextField.appendText(msg)
I've got a short question. How can I update a TextField without using an
I've got some text in a textfield, they start of with 6 characters and
Use a hidden field will fix my issue... i got it.. Hi All, I
iam developing one application.In that i use the label and textfield in same line.Every
I've got a sublass of UITableViewController which I use to add a new data
I got 2 DateTime field and i use datepicker for user to choose a
I've got a little problem with uitextfield. I use two of them in a
I've got a single-screen app in which you find two textfields (object and key)

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.