william
william

Reputation: 113

Android chrome: avoid keyboard to hide when icon is pressed

Chrome's default behavious is to hide the keyboard, when this one is open/shown and I click in any part of the screen. I want to achieve to prevent it from hidding if I click in a specific DOM element. Is that possible using JS?

window.onclick = function(event) {
  var sendMsgBtn = document.getElementById("send-msg-icon");
  if (event.target == sendMsgBtn) {
    //what to do here
  }
}

Upvotes: 0

Views: 180

Answers (1)

vik24
vik24

Reputation: 26

If you focus on a <input> or <textarea> element (it may be hidden) and then you click on it, the keyboard will not hide

window.onclick = function(event) {
   var sendMsgBtn = document.getElementById("send-msg-icon");
      if (event.target == sendMsgBtn) {
        var input1 = document.getElementById("input1");
        input1.focus();
        input1.click();
      }
  }

Upvotes: 1

Related Questions