Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

Handle .show()/.hide() of the virtual keyboard on mobile devices with HTML5 target #1257

Open tcdude opened 3 years ago

tcdude commented 3 years ago

Is your feature request related to a problem? Please describe. Currently on mobile OS using the HTML5 target in a browser (tested on Android with Chrome and Firefox), the call to show the virtual keyboard (Keyboard.get().show()) gets ignored and thus makes it impossible to use text input on such devices.

Describe the solution you'd like I would like the HTML5 target to distinguish whether it is running inside a browser on a touch only device with no physical keyboard. If that is the case, calls to Keyboard.get().show() / .hide() should show/hide the virtual keyboard and handle text input properly.

Describe alternatives you've considered I've considered to also export as native apps to iOS and Android and make my website detect when it is running on those platforms and displaying links to the respective store. This solution takes up additional time (publishing on the stores and passing app screening), comes with added cost (developer accounts on both platforms) and potentially deters some users because they first have to download an app. Another solution for my particular case, where the input is only numbers based is to create a number pad widget in my app that gets displayed when a mobile browser is detected. This solution is only viable for number only input and doesn't address the underlying problem.

Additional context I found something about the topic on SO show-virtual-keyboard-on-mobile-phones-in-javascript that could potentially be helpful to solve this. IIRC in SDL2 one can specify the rect where the text input takes place, if something like that would be added to Kha, maybe it would be possible for Kha to add an invisible layer on top of text inputs, that triggers the virtual keyboard? Not sure, not really an area of expertise of mine.

mundusnine commented 3 years ago

I will have a look at this in the coming days. Will report back.