Skip to main content
When a keyboard appears, iOS and Android both attempt to resize or reposition the WebView automatically. If your web app is already full-height and manages keyboard avoidance in JavaScript, this native adjustment creates a white gap below the keyboard and disrupts your layout. The preventdefault://autoscroll scheme disables that native behavior and lets you opt back in at any time.

Installation


How it works

Call preventdefault://autoscroll with enabled=false to stop the native layer from moving the WebView when the keyboard opens. Call with enabled=true to restore the default behavior.
To restore native behavior later:

Disable on app load

The most common pattern is to disable native keyboard resizing once on startup, before any input is focused. This ensures the WebView never shifts position during the session.

Selectively re-enable for specific inputs

If one part of your app relies on native scroll behavior - such as a form that does not manage its own keyboard avoidance - you can toggle the mode per interaction.

Platform behavior

The scheme maps to different native APIs on each platform but produces the same result - the WebView holds its position when the keyboard appears.

Resources

NPM Package

despia-native