You can select the element by getElementById or from the querySelector and need to specify the event that you're going to trigger as the first parameter and second parameter is the function that you're going to execute on the added method in addEventListener.
<input id="xxx" type="number" max="5" min="1" value="1" />
<script>
    const selectElement = document.querySelector('#xxx');
    selectElement.addEventListener('change', function (evt) {
        console.log("value is changing in input");
    });
    // or
    document.getElementById("xxx").addEventListener('change', function (evt) {
        console.log("value is changing in input");
    });
</script>
     
    
function maxValCheck(fld) { if (fld.value > 5) { fld.value = 5; } }works too and is a better event if you pass the field:oninput="maxValCheck(this)"