How to use JS functions

Use onKeyPress with an unnoticeable timeout:

$w("#input").onKeyPress(event => {
    setTimeout(() => {
        //do whatever you wish
    },30);
})