JS is ok, it’s the DOM APIs that are verbose. I mean this is just to handle the enter key:
f.addEventListener('keypress',e=>{if(e.keyCode==000) etc()}) f.addEventListener('keypress',e=>{if(e.keyCode==000) etc()}) f.addEventListener('keypress',e=>{...})
With the older but essentially equivalent f.onkeypress=e=>{...}
and save 18 characters. You can even use `onkeyup` and save 3 more characters.