Enter key in Virtual Keyboard Android (DEF-1866) (SOLVED)

I was using dirtylarry for simple GUI input name implementation, but there is issue I facing. Is ENTER key behavior in virtual keyboard and actual keyboard work same? I mean, in virtual, did it really work with action.released / action.pressed?
Because when i press ENTER in virtual keyboard, nothing happend… but it works fine in actual keyboard

Thanks.

The virtual keyboard on a mobile device will not generate key actions (except for backspace). One could argue that perhaps also enter should generate a key event. There’s a similar issue on HTML5 where you get both an enter key event and a text event (with keycode 13). This is reported in DEF-1866. Let’s see if we can do something about it soon.

A workaround solution for you is to check if action.text is empty and treat that as the enter key on mobile.

Ah i see… ok, hope you guys can fix it soon.

Just want to ensure this in code, do you mean with empty text enter key on action.text is action.text == “” ? or nil ? or " " ?

Thanks

I haven’t tried but I’m thinking that you could do:

local is_android = sys.get_sys_info("system_name") == "Android"

function on_input(self, action_id, action)
    if action_id == hash("text") and is_android and action.text and action.text == "" then
        print("enter?")
    end
end

I was trying your suggest, but still cant. I just not sure if action.text == “” is equiv with enter key on virtual. And also maybe the right sys is sys.get_system_info().system_name

Fixed in 1.2.135

1 Like

Just to make sure, it’s now possible on enter key from action.pressed or just capture enter from vkeyboard?

The KEY_ENTER binding in key bindings now correctly trigger when you press the enter key on a virtual keyboard (at least on the ones we tried).

Would this work in HTML5 too? This module works great, but the Enter key doesn’t seem to trigger:

https://britzl.github.io/Defold-Input/

No, I believe there’s issues with reading keyboard input from a virtual keyboard on mobile html5 (for instance Safari). Give it a try to confirm!

I refreshed my memory with this thread and I’ve decided to turn back to safety with a virtual keyboard made with gui nodes. :slight_smile:

1 Like