an input field changes its value via jquery (not by a human action), like this:
$("#code").val(9); .
How can I intercept the change event (or similar) without changing or add new lines to code that changes its value.
Programmatically setting value does not trigger any user events so you must trigger one yourself after the new value is set.
I used a change event but you could use others like the "input" event
$("#code").on('change', function(){
console.log('changed value =', this.value);
});
$("#code").val(9).change();
// or
// $("#code").val(9).trigger('change');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="code"/>