Detecting android softkeyboard show/hide events

前端 未结 2 1669
既然无缘
既然无缘 2020-12-15 08:11

I am trying to detect showKeyboard and hidekeyboard events on phonegap. For that purpose, on deviceready event I placed following code

2条回答
  •  悲哀的现实
    2020-12-15 08:21

    Using ionic-plugin-keyboard, the events native.keyboardshowand native.keyboardhide are fired, even in fullscreen / immersive Mode:

    Example Code:

    document.addEventListener('deviceready', 
      function(){
        // disable immersive mode  on Android when keyboard is shown
            try {
          if (cordova.platformId == 'android') {
            AndroidFullScreen.immersiveMode(false, false);
            window.addEventListener('native.keyboardshow', function (e) {
              AndroidFullScreen.showSystemUI(false, false);
    
            });
            window.addEventListener('native.keyboardhide', function (e) {
              AndroidFullScreen.immersiveMode(false, false);
            });
          }
        } catch (error) {
          console.log('deviceready - ' + error);
        }
    }, false);
    

提交回复
热议问题