I am using Cordova 11.1.0 to build an android app. I am trying to override the backbutton event to ignore the action completely so that it doesn't go back to the previous page.
This the code I am using:
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown(e) {
e.preventDefault();
alert('Back Button is Pressed!');
}
But it doesn't work. I built the app and installed it on my phone to check but it still goes back to the previous page and I don't see the alert too. Kindly help and thanks in advance.