How to determine if the device keyboard was hidden by pressing the Back button?

I am creating a chat in a game and I need to hide the input field if the user presses the Back button on their device. How can I detect when the device keyboard has been hidden?


I don’t think you can detect that from inside a webpage, you could instead use the page visibility API to see if the page is visible or not.