JSFiddle - React, Tailwind, and code Playground
HTML
<input id="text" type="text" placeholder="Enter your name..."
onkeyup="return submitName(event);">
<button id="submit">Submit</button>
JavaScript
function submitName(e) {
if (e.code === 'Enter') {
document.getElementById('submit').click();
}
}
document.getElementById("submit").onclick = function() {
alert('Clicked!');
}