Try this:
<input type="text" placeholder="some text" class="search" onkeydown="search(this)"/>
<input type="text" placeholder="some text" class="search" onkeydown="search(this)"/>
JS Code
function search(ele) {
if(event.key === 'Enter') {
alert(ele.value);
}
}