Android keyboard covering content

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SF123

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!

:bust_in_silhouette: Reply From: Wakatta

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

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

SF123 | 2022-05-10 17:48

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

Wakatta | 2022-05-10 22:18

Thank you :slight_smile:

SF123 | 2022-05-11 18:05