Categories
JavaScript Answers

How to force the soft keyboard to hide with JavaScript?

Spread the love

Sometimes, we want to force the soft keyboard to hide with JavaScript.

In this article, we’ll look at how to force the soft keyboard to hide with JavaScript.

How to force the soft keyboard to hide with JavaScript?

To force the soft keyboard to hide with JavaScript, we call blur when we focus on the input.

For instance, we write

<input type="text" id="phone-number" onfocus="blur();" />;

to call blur when we focus on the input by setting the onfocus attribute to blur().

Conclusion

To force the soft keyboard to hide with JavaScript, we call blur when we focus on the input.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *