JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="password">
<input type="text" id="hiddenValue">

JavaScript

var field = document.getElementById("password")
var realValue = "";
field.onkeydown = function(evt){
    realValue += String.fromCharCode(evt.keyCode)      
    this.value = realValue.replace(/./g,"*");      
   document.getElementById("hiddenValue").value = realValue
  return false;   
}