Ouça o evento de fechamento do teclado em JS
// event listener is triggered when keyboard is open or closed
window.visualViewport.addEventListener('resize', event => console.log(event.target));
Anxious Alligator