0 votes

I'm making a chat app using Godot (and PHP/MySQL for the backend) and it's done, but it gets hidden by the android keyboard when I type anything.

Is there any way to have the whole screen move up when the keyboard opens, and move back down when it closes, like in some applications?

Thanks in advance!

Godot version Godot Engine 3.3.3 (Steam)
in Engine by (234 points)

1 Answer

+1 vote
Best answer

If you are using Control nodes and they are not anchored you can resize the chat area by subtracting the keyboard height

#store the height to later reset it
var old_height = $chat_node.rect_size.y

#on keyboard shown
var kb_height = OS.get_virtual_keyboard_height()
$chat_node.rect_size.y -= kb_height.y

#on keyboard hidden
$chat_node.rect_size.y = old_height
by (6,876 points)
selected by

Sorry, this is a while later, but how would I detect when the keyboard is shown?

Hmm nice question and not sure if there is a better solution.

Try calling OS.get_virtual_keyboard_height() and if it returns 0 then its not visible.

func is_virtual_keyboard_shown():
    return OS.get_virtual_keyboard_height() != OK

Thank you :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.