How to prevent keyboard push up webview at iOS app using phonegap

On focus, set window.scrollTo(0,0); This prevents keyboard from pushing up webview completely

$('input').on('focus', function(e) {
    e.preventDefault(); e.stopPropagation();
    window.scrollTo(0,0); //the second 0 marks the Y scroll pos. Setting this to i.e. 100 will push the screen up by 100px. 
});

If you don’t want to set a static value for your Y scroll position, feel free to use this short plugin I’ve written that automatically aligns the keyboard underneath the input field. It’s not perfect, but it does the job. Just call this on focus as shown above:

setKeyboardPos(e.target.id);

Leave a Comment