Right now I’m on my phone and I don’t remember how to do that.
But I remember that that was one of the problems I addressed with the InputBox custom component: Input_box() and alert2()
You can have a look at the code to see how I addressed it, or you can use the custom component, which manages the focus for you.