How to detect keyboard show/ hide event in jquery for mobile web application

后端 未结 5 1940
故里飘歌
故里飘歌 2020-12-30 01:00

I am working on web base mobile (HTML) application. Is there any way to detect keyboard event like when keyboard is visible and keyboard hide, base on that I can control o

5条回答
  •  感情败类
    2020-12-30 01:08

    You can use resize event to get if keyboard is appearing or not

    $(document).ready(function(){
      var _originalSize = $(window).width() + $(window).height()
      $(window).resize(function(){
        if($(window).width() + $(window).height() != _originalSize){
          console.log("keyboard show up");
          $(".copyright_link").css("position","relative");  
        }else{
          console.log("keyboard closed");
          $(".copyright_link").css("position","fixed");  
        }
      });
    });
    

提交回复
热议问题