I want to use the back button of Android to go back into a WebView (it's in a Fragment), so I put up this code in Kotlin:
catWebView.setOnKeyListener { _, keyCode, _ ->
if (keyCode == KeyEvent.KEYCODE_BACK && catWebView.canGoBack()) {
catWebView.goBack()
}
return@setOnKeyListener true
}
and that works, but with a problem: when I tap the back button, the WebView goes all the way back to the first page opened, and not by single steps...
How can I solve it? Thank you!