JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' />
JavaScript
var obj = {
typedValue : "",
onKeyPress : function (e) {
e.preventDefault()
var input = document.querySelector('input')
//this.typedValue += String.fromCharCode(e.keyCode)
console.log(this.typedValue)
const hiddenPass = this.typedValue.replace(/./g, '*')
input.value = hiddenPass
}
}
document.querySelector('input').addEventListener('input', function(e) {
obj.onKeyPress(e)
})