JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="txt1" class="search-bar-input" data-searchButtonId="btn1" />

JavaScript

function handleKeyPress(event) {
   if (event.keyCode === 13) {
        console.log(event.keyCode + this.getAttribute("data-searchButtonId"));
   }
}

window.onload = function(){
   document.getElementById("txt1").onkeyup = handleKeyPress;   
}