I have a question.
Is it possible for input to be always focused like in Telegram desktop app?
Question posted in Telegram API
A comprehensive official documentation can be found here.
A comprehensive official documentation can be found here.
2
Answers
If they did it for Telegram desktop then it must be possible, right? Just a matter of how.
There’s a few ways to do this.
You can use the autofocus attribute as Ram mentioned in the comment. Simple, but I like to avoid HTML attributes for this kind of DOM manipulation because you’re at the mercy of the browser understanding and implementing the attributes.
You can also give it a tabindex 1, but that means you’ll have to keep track of your tabindexes for all focusable elements.
You can also write up a quick function under document ready like
These are only a few solutions I could think of off the top of my head.
The simplest way is this:
I hope I helped you