How to insert text at cursor's current position?

Hi there,

I’d use the onInput() event handler to modify the input, this way the symbol will be automatically inserted.

$w("#input").onInput(event => {
    const value = event.target.value;
    if (value.includes('$')) {
        const modValue = `$${value.replaceAll('$', '')}`;
        event.target.value = modValue;
    } else {
        const modValue = `$${value}`;
        event.target.value = modValue;
    }
})

What the code does is check if the text has a symbol ($) or not, and add the symbol at the beginning if it doesn’t, and if it has a symbol, remove it from the text, then add it at the beginning of the text.