Hide virtual keyboard on mobile with Jquery/Javascript (Mobiscroll)

Dennis Anderson picture Dennis Anderson · Jul 23, 2014 · Viewed 11.5k times · Source

There are a lot of questions about this. But they all talk about leaving the focus on a field. Here is my problem:

I have a input type field. When the user clicks on it, it will open my custom mobiscroll feature. and in some cases like by Android 2.* or windows surface tablets it shows the virtual keyboard as well ! How can i code a case that the virtual keyboard will never appear !

Who can help me :)

Answer

R3tep picture R3tep · Jul 23, 2014

To remove the keyboard you need to lose the focus on the active element. No other solution.

So display your pop-up and after remove the focus.

Example:

function clickInput() {
    openPopUp();
    document.activeElement.blur(); // lose focus on the active element and hide keyboard
}

UPDATE:

I do not know "mobiscroll". But to hide the keyboard you need to lose focus on the active element.

document.activeElement && document.activeElement.blur();
// This code remove the keyboard constantly.