onfocus="blur()" only on mobile devices

Viewed 171

I have created a custom soft keyboard for mobile devices. The problem is that each time I click an input box it pops up my custom keyboard but it also pops up a soft keyboard of the device. Now, I can do

<input type="text" class="myCustomKeyboard" onfocus="blur()">

This solves the problem of keyboard popping up in mobile devices but this also means I have to use my custom keyboard on a desktop

I am checking for mobile devices using:

 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { 
        Keyboard.init();
     }

Is there a way to stop keyboard popup without losing the ability to type using keyboard in desktop devices?

1 Answers

Remove onfocus="blur()" and replace it with inputmode="none", it will solve all the problem and works like a charm ^^.

https://inputmodes.com/ can verify the HTML 5 input modes in here

Related