I was trying to capture the enter key in a input field and came across this post. Attaching the solution that I worked out for everyone’s reference:
inp = createInput('');
inp.elt.addEventListener('keyup', ({key}) => {
if (key === "Enter") sendMessage() });
function sendMessage() {
// blah...
}