'keyboard doesn't open in ios on focus

I am currently developing the login aspect inside a custom browser on ios. I want to open the keyboard when a user clicks on an input element. When an input element gets clicked, I set the 'autofocus' attribute for that element, followed by a focus on the element. However, these steps are not sufficient for opening the keyboard. I have tried methods present in the link: IOS show keyboard on input focus, but nothing works. The software version I'm working with is 14.4.2.

I am testing the app on an iPad.

var ev = new MouseEvent('click', {
                                       'view': window,
                                       'bubbles': true,
                                       'cancelable': true,
                                       'screenX': x,
                                       'screenY': y
                                   });

//x and y are the screen coordinates of the point where a user clicks.
var el = document.elementFromPoint(x, y); 
console.log("Clicked element: "+el); //print element to console
                                   
el.addEventListener('click', function() {
                    el.setAttribute('autofocus', 'autofocus');
                    el.focus();
});
el.dispatchEvent(ev);


Solution 1:[1]

If you are testing your app in Simulator , make sure I/O -> Keyboard -> Connect Hardware Keyboard is unchecked. Otherwise, you won't see the keyboard appear.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marco