I have a JavaScript application which also runs on mobile devices (Android, Chrome Browser). The requirement is a input field which has inital focus without showing the Softkeyboard. This will be used as a scan field. Only when the user manually type/touch into the field the keyboard should appear.
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();
});
}
It works quite properly except hiding the keyboard within the "focusout" event. Can someone help me? Thank you in advance for your assistance.
I whould expect that the Softkeyboard will be closed after calling the hide() method but this isn't the case. I'am not sure if this depends on the events (Pointerevents, Focusevents).