JSFiddle - React, Tailwind, and code Playground
HTML
<form id="myForm" method="POST">
<input id="myText" type="text" />
<input type="text" />
<input type="submit" value="Submit!" />
</form>
JavaScript
$('#myText').on('focusin', function() {
console.log('focusin');
$(this).off('keydown').keydown(function(event){
if(event.keyCode == 13) {
console.log('enter!');
event.preventDefault();
return false;
}
});
});
//for testing only
$("#myForm").on("submit", function(e) {
e.preventDefault();
console.log('submitted')
});