0

I am trying to track the opening of the keyboard in order to perform some actions when opening it.

I used various methods for example:

Keyboard.addListener('keyboardWillShow', info => {

});
Keyboard.addListener('keyboardDidShow', info => {

});

But for some reason, keyboardWillShow and keyboardDidShow are triggered not when the keyboard is opened, but when it is closed or when you start typing something into the input. Why can there be such a strange behavior?

  • Check this out. https://stackoverflow.com/questions/25216749/soft-keyboard-open-and-close-listener-in-an-activity-in-android – fix Aug 29 '23 at 11:45

1 Answers1

0

Refering to the Ionic doc for angular, here is the doc of the Keyboard lyfecicle : https://ionicframework.com/docs/developing/keyboard

import { Platform } from '@ionic/angular';

constructor(private platform: Platform) {
 this.platform.keyboardDidShow.subscribe(ev => {
 const { keyboardHeight } = ev;
 // Do something with the keyboard height such as translating an input above 
the keyboard.
 });

this.platform.keyboardDidHide.subscribe(() => {
// Move input back to original location
 });
}
Q.Rey
  • 305
  • 4
  • 18