Show keyboard when game is played on phone

Monkey Targets Forums/HTML5/Show keyboard when game is played on phone

sandav(Posted 2015) [#1]
I've made a game which I'm targeting towards the html5 platform. For the most part it works fine when the webpage is visited from PCs, or from phones (I have only tested on Android). The problem is that when the player runs out of lives and goes to the high-scores screen, I take text input using getchar, but the phone doesn't bring up the keyboard, so phone users can't put their name in. What's the easiest way to fix this? Can I make the html canvas be recognized as an input field somehow?

I've seen the htmlgui module, which I think would work. But I like to use my own bitmap font, and I also want to try to make it as easy as possible to compile directly to other targets if I want to make it into an app eventually.

Thanks for any help.


StoneFaceEXE(Posted 2015) [#2]
There are commands
EnableKeyboard()
DisableKeyboard()
they toggle NATIVE keyboard on android and iOs

I wrote this piece of code to handle it better too: (Because if sometimes apps crash if you call DisableKeyboard() twice in a row)
Global _sys_keyboard:Bool

Function ToggleKeyboard:Void()
	If _sys_keyboard = False
		EnableKeyboard()
		_sys_keyboard = True
	Else
		DisableKeyboard()
		_sys_keyboard = False
	End If
End Function
'═════════════════════════════════════'
Function SafeEnableKeyboard:Void()
	If _sys_keyboard = False
		_sys_keyboard = True
		EnableKeyboard()
	End If
End Function
'═════════════════════════════════════'
Function SafeDisableKeyboard:Void()
	If _sys_keyboard = True
		_sys_keyboard = False
		DisableKeyboard()
	End If
End Function



Simonsuuri(Posted 2015) [#3]
Thanks stoneface, from me too :)


Yeshu777(Posted 2015) [#4]
Just a note, EnableKeyboard and DisableKeyboard don't do anything on HTML target.

Yeshu777