Hello and welcome to SF Stack Exchange!
I have created a LWC out of the code you have shared. Please take a look at this playground.
In case the playground disappears I am sharing the code here.
<p>Click the input field to select the contents of the text field.</p>
Name: <input type="text" id="myText&...