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

199
Views
JavaScript detect enter event in WYSIWYG tool vs. a textarea

I am working on a plugin for Slack and making good progress. For the Slack input bar (shown below) I can now "convert" recognized words in user's text into links by addEventListener for a click to the submit button.

enter image description here

enter image description here

Then (based on the HTML structure of the Slack entry tool), I can capture the <p> elementNode containing the user text this way:

// don't laugh, it works reliably
e.target.parentElement.parentElement.parentElement.parentElement.parentElement.childNodes[1].firstChild.firstChild.firstChild

and convert it upon submission.

Since the element is a <p> and the user is using a WYSIWYG editor, I need to also capture <Enter>, but I can't bind it to the <p> element since that doesn't have an onkeypress event (like a textarea).

Is there a way to capture the <Enter> event when in the wysiwyg so behave the same as the click event on the button? I know there are many JavaScript event features I'm not yet aware of.

about 4 years ago · Juan Pablo Isaza
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!