Input field interaction - text input overwrites existing content

i am struggling with the interaction of an input field. I want to achieve the following behavior:
empty input field: it behaves like the out of the box Protopie input component.
after content was entered: I want it to select the text on “focus in” and overwrite it with the new text input.
I managed to prototype the highlighted text with a text component that mirrors the input field content, but I am struggling with the clear and overwrite part. I need to somehow reset the “content” variable, but add whichever key was pressed to the variable at the same time.

Maybe anyone an idea or already prototyped that behavior? Any pointers would be appreciated.

https://cloud.protopie.io/p/f0c54314c2893d94cb1f6998