Onchange javascript

hello everyone

how i do a calcula a field in realtime with jaavascript, i m try this

    document.getElementById('gc-form-quantity').addEventListener('change', function(event) {
        // Handle the event here
        console.log('Input value changed:', event.target.value);
    });

this is a possiblity?