JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" />
<input type="hidden" />
<input type="button" value="ok" />

JavaScript

$(function(){
    $(":text").on("keyup", function(){
        $(":hidden").val($(this).val()).trigger("propertychange");
    });
    
    $(":hidden").on("input propertychange", function(){
       alert($(this).val()); 
    });
    
    $(":button").on("click", function(){
        alert($(":hidden").val()); 
    });
});