HTML5 input on mobile

There is no way to implement gui.show_keyboard() because of browser limitations.
But I found a nice workaround for keyboard input in html5 builds.

It is possible to show a native popup with input request using this method:

M.get_input(explanation, default_text)
 if html5 and is_html5_mobile() then --is_html5_mobile()  is your way to check if it's mobile html5
        local result = html5.run("window.prompt('".. explanation.."', '".. default_text.."')")
        if result ~= "null" then
            return result
        end
    end
end

iOS:

Android:

21 Likes

Also there is another way to handle HTML5 mobile keyboard:

Since Defold 1.3.7 we got the html5.set_interaction_listener. In this callback we able to use any different method to show the mobile keyboard. It should work inside browser user input event.

I’ve check this module: keyboard.lua from this thread. It’s works well inside html5 interaction callback. Probably for someone it will be a good way to handle this mobile input

6 Likes