Home  >  Q&A  >  body text

javascript - How to determine the hidden buttons of the mobile soft keyboard

is the down arrow that closes the keyboard

Suddenly discovered that alert(keyCode)
This button has no code on android

How to deal with it

How to judge Closed

三叔三叔2694 days ago839

reply all(3)I'll reply

  • 仅有的幸福

    仅有的幸福2017-06-28 09:29:03

    Tongzhun, I encountered this problem a long time ago, but I haven’t found a more complete answer

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-28 09:29:03

    When the user calls out the soft keyboard, the page will trigger the resize event, and the page size will become smaller. The height is only the original height minus the keyboard height, which is generally less than 500. At the same time, there are almost no screens on the market with the original height less than 500. Mobile phone, so after resize is triggered, it is judged that if document.body.clientHeight>500
    , the soft keyboard is regarded as being closed

    There should be compatibility issues. . . . . . . . . . . . . .

    reply
    0
  • 天蓬老师

    天蓬老师2017-06-28 09:29:03

    android can listen to resize events

    var winHeight= $(window).height();
        $(window).resize(function(){
            var thisHeight=$(this).height();
            if(winHeight - thisHeight >50){
                $('.form_scrollTxt').hide();
                $('.form p').css('margin-bottom','2px')
            }else{
                $('.form_scrollTxt').show();
                $('.form p').css('margin-bottom','13px')
            }
        });

    reply
    0
  • Cancelreply