JSFiddle - React, Tailwind, and code Playground
HTML
<div id="someContainer">
<p>Press enter in any of these inputs:</p>
<input type="text">
<input type="text">
<input type="text">
</div>
JavaScript
document.getElementById("someContainer").onkeypress = function(e) {
e = e || window.event;
var target = e.target || e.srcElement;
if (e.keyCode === 13 && e.target.tagName === "INPUT") {
goButton();
}
};
function goButton() {
alert("Enter was pressed!");
}