Help with using input values with variables along with if, else if code

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...
}
2 Likes