JSFiddle - React, Tailwind, and code Playground

HTML

<input id=field />
<ul id=log>

JavaScript

$('#field').keyup(function() {
    var $field = $(this);

    // this is the value before the keypress
    var beforeVal = $field.val();

    setTimeout(function() {

        // this is the value after the keypress
        var afterVal = $field.val();
        
        $('#log').prepend(
            $('<li></li>').text('value before: ' + beforeVal + '; value now: ' + afterVal)
        );
    }, 0);
});