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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:17:44+00:00 2026-06-14T12:17:44+00:00

In an input box if you press RETURN/ENTER you submit the form. In a

  • 0

In an input box if you press RETURN/ENTER you submit the form. In a textarea pressing RETURN produces a line-break. How do you make a that on RETURN keydown instead of producing a line-break submits the form and in SHIFT+RETURN produces the line-break? (Like fb and other sites do)

Is there some way to do it with just HTML? If not how can it be done with JS?

This is what I am trying right now:

$('#conversationForm textarea').keydown(function(e) {
    e = e || event;
    if(e.keyCode == 13 && !e.shiftKey) {
        $("#conversationForm").submit();
        return false;
        }
    });

However when I haven’t been able to prevent the line-break from happening. (If you press RETURN the line break is visible before submitting.)

  • 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-14T12:17:46+00:00Added an answer on June 14, 2026 at 12:17 pm

    Using jQuery, and similar to the other answers, but including your request to make shift not submit but just do a line break

    $("#mytextarea").keypress(function() {
      if(event.which == 13 && !event.shiftKey)
      {
          //submit your form here  i.e. form.submit();
      }
    });​
    

    Here if shift is pressed, it won’t submit and just give you a line-break.

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

Sidebar

Related Questions

I have an input box in html form and onKeyPress of that box I
I have an input box that takes values from 0-100. I want to prevent
My site has an input box, which has a onkeydown event that merely alerts
I've got an input box that allows UTF8 characters -- can I detect whether
I'm trying to make the input box (on the JSFiddle attached) with the serialize
I have an input box that as you type displays a div called suggestions
I have a select box and an input box that submits to a view
Help me optimize a regular expression <form id='myForm'> Enter phone number:<input type=text id='idMyText' name=myText
I have a simple input form that consists of a single textbox and an
I'm looking for a cross browser solution to handling carriage return, to submit input

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.