w3c / virtual-keyboard

VirtualKeyboard API
https://w3c.github.io/virtual-keyboard/
Other
16 stars 3 forks source link

hide() method not working in manual mode on Android (Chrome) #23

Open bschraml opened 7 months ago

bschraml commented 7 months ago

I want to show the softkeyboard only when the user taps into the input field. I'am using this code:

if ('virtualKeyboard' in navigator) {

    const myInput = getElementById("myinput");

    myInput.setAttribute("virtualkeyboardpolicy", "manual");

    navigator.virtualKeyboard.overlaysContent = true;

    myInput.addEventListener("pointerup", () => {
        navigator.virtualKeyboard.show();
    });

    myInput.addEventListener("focusout", () => {
        navigator.virtualKeyboard.hide();
    });

}

The show method works properly. But the hide() method within the focusout event doesn't. The softkeyboard will not be closed. I tried a lot of things but I don't find any solution. I guess it depends either on the event type or on the Android operating system.