Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Enter key behaviour Angular and Material form

In my forms in a MEAN application I have:

<form novalidate [formGroup]="thesisForm"
  enctype="multipart/form-data"
  (keydown.enter)="$event.preventDefault()" (keydown.shift.enter)="$event.preventDefault()">

I do this because occasionally people press enter without wanting to submit the form. So to avoid accidents I add the prevent default.

BUT this results in text areas not reacting to the enter key and I cannot introduce line spaces. If I write the text and copy paste it I can add the new lines, but not when pressing enter . How can I fix this so that I can use the text area normally?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can leave preventDefault() on form element, and add (keydown.enter)="$event.stopPropagation()" on particular element (like textarea) and hitting enter there won't trigger a submit, and will allow new line in multi-line inputs.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!