1 // Prevent form submission on enter key press inside inputs
2 const listener = e => {if(e.keyIdentifier==='U+000A'||e.keyIdentifier==='Enter'||e.keyCode===13){if(e.target.nodeName === 'INPUT' && e.target.type !== 'textarea'){e.preventDefault();return false;}}};
3 document.addEventListener('keydown', listener, true);