Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda