JSFiddle - React, Tailwind, and code Playground
HTML
<input type="number" id="txt" value="Hello"
onkeydown="myFunction(event)"
min="-100"
max="100"
step="0.05"
>
JavaScript
function myFunction(e) {
var min = -100;
var max = 100;
var txtValue = document.getElementById("txt").value;
var pressedValue = e.key;
var combined = parseFloat(txtValue, pressedValue);
console.log( `OLD:${txtValue}\nNEW:${pressedValue}\nCOMBINED:${combined}`);
if (combined > max) {
e.preventDefault();
console.log('ohhw snapp');
}
}