JSFiddle - React, Tailwind, and code Playground

HTML

<input id="input1" onkeypress="getKey1(this,event)"/>
<input id="input2"/>

JavaScript

function getKey1(obj,e) {
    alert(obj.id+e.keyCode);
}

function getKey2(e) {
    alert(this.id+e.keyCode);
}

document.getElementById("input2").onkeypress = getKey2;