this may work for you
<input type="number" id="interval_size" onkeyup="valueChanged()">
you have onkeypress that triggers when the user press a key but the input has not changed jet but
The onkeyup event occurs when the user releases a key (on the keyboard). so the input has already changed