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.
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.