var el = document.getElementById("textarea") el.addEventListener("keydown", (e)=>{ if(e.key === "Enter"){ // do something here } })