title: React: How to submit a form with <textarea> with enter key and without a submit button with React Hooks?
body: <p>Halo guys I am quite new to react and I want to submit a form with only a text area with <code>enter</code> key press. I followed some of the SO questions but still no luck as it is not getting submitted. I also want to clear the text area after the submit. How can I do it with the below code?</p>
  <p>This is the code I currently have.</p>
  <pre><code>const { register, handleSubmit, control, errors } = useForm();
  
  const CommentOnSubmit = (data) =&gt; {
      let formData = new FormData();
  
      formData.append('content', data.content);
      formData.append('user', user?.id);
  
      axiosInstance.post(`api/blogs/` + slug + `/comment/`, formData);
  } ;
  
  // const commentEnterSubmit = (e) =&gt; {
  //     if(e.key === 'Enter' &amp;&amp; e.shiftKey == false) {
  //         return(
  //             e.preventDefault(),
  //             CommentOnSubmit()
  //         )
  //     }
  //   }
  
  &lt;form noValidate onSubmit={handleSubmit(CommentOnSubmit)}&gt;
                  &lt;div className=&quot;post_comment_input&quot;&gt;
                      &lt;textarea
                          type=&quot;text&quot; 
                          placeholder=&quot;Write a comment...&quot;
                          name=&quot;content&quot;
                          ref={register({required: true, maxLength: 1000})}
                      /&gt;
                  &lt;/div&gt;
                  &lt;div className=&quot;comment_post_button&quot;&gt;
                      &lt;Button type=&quot;submit&quot; variant=&quot;contained&quot; color=&quot;primary&quot;&gt;comment&lt;/Button&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
  </code></pre>
  <p>Please do help.</p>
  <p>Thanks a lot.</p>