I'm using the following code to capture the back button press in a Cordova Android 4.0.0 App with Crosswalk:
// Wait for device API libraries to load
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown(e) {
e.preventDefault();
alert("Back button pressed!");
}
The button handler is called but using e.preventDefault() is not working and the App is still being closed. Does anyone know why or a workaround for this?