Having exact same issue. When playing with KB&M and I go into Chat it defaults to the on-screen keyboard used by the controller instead of just staying at the chat box in-game. Since the on-screen keyboard is an overlay used by the console itself, clicking the "hide keyboard button" or whatever it is called in game using the mouse does nothing nor does clicking the 'X'. The only way to remove the on-screen keyboard is to turn back on my controller and press the 'B' button. That allows me to type and send messages using keyboard, but issue occurs again when I close and reopen chat. Minecraft knows when keyboard and mouse is being used or when the controller is being used so why this issue even exists is beyond me. It highly defeats the purpose of having the option of playing with KB&M. Please fix this issue! It has been present since the beginning of the "Better Together" update and various other more minor issues have been fixed but this has been ignored.
Minecraft recognizes when keyboard & mouse is being used. All we need is to ignore or bypass the call to bring up the default on-screen keyboard used by the controller. This overlay can only be taken away via pressing 'B' on controller, which absolutely sucks for us using KB&M as it requires us to constantly have our controller turned on just to chat with KB&M.
I had already commented a solution similar to this, but it defeats the purpose of using keyboard and mouse. I should not have to keep my controller on constantly, drainging battery power, just to send a message in chat.