JSFiddle - React, Tailwind, and code Playground
by karim79
HTML
<form id="myForm">
<input id="test"/>
<input/>
</form>
JavaScript
// bind to the form instead of window
jQuery('#myForm').bind('keypress', function(e) {
// submit only if 'Enter' pressed on specific element
if (e.keyCode == 13 && e.target.id == "test") {
$(this).submit();
}
});