Sometimes, we want to hide the Android keyboard using JavaScript.
In this article, we’ll look at how to hide the Android keyboard using JavaScript.
How to hide the Android keyboard using JavaScript?
To hide the Android keyboard using JavaScript, we set hide it after we focus on the input.
For instance, we write
const field = document.createElement("input");
field.setAttribute("type", "text");
document.body.appendChild(field);
setTimeout(() => {
  field.focus();
  setTimeout(() => {
    field.setAttribute("style", "display: none;");
  }, 50);
}, 50);
to call field.focus to focus on the input.
Then we call field.setAttribute with 'style' and 'display: none' to hide the field.
We do both with a delay by putting them in a setTimeout callback.
Conclusion
To hide the Android keyboard using JavaScript, we set hide it after we focus on the input.
