Crisiiii
Crisiiii

Reputation: 409

Event native keyboardshow not firing in Ionic 3

I have an app in Ionic 3, and I would like to use the event native.keyboardshow to hide the keyboard, but the event is never fired. I'm declaring the event inside the life hook onInit like this:

ngOninit() {    
  window.addEventListener('native.keyboardshow', function(){
    document.body.classList.add('keyboard-open');
    alert('just to check if it's working in mobile);
  });
}

Any ideas why the event is not working? Thank you!

Upvotes: 0

Views: 393

Answers (1)

Grenoblois
Grenoblois

Reputation: 559

install the Cordova and Ionic Native plugins:

$ ionic cordova plugin add ionic-plugin-keyboard
$ npm install --save @ionic-native/keyboard

Usage

import { Keyboard } from '@ionic-native/keyboard';

constructor(private keyboard: Keyboard) { }

...

this.keyboard.show();

this.keyboard.close();

source : https://ionicframework.com/docs/native/keyboard/

Upvotes: 1

Related Questions