Answer the question
In order to leave comments, you need to log in
How to intercept phone button press in Cordova?
Hello. I am writing an application in Cordova. What plug-in can intercept the pressing of the phone button? Now the button in the form of an arrow "Back" interests. As far as I understand, this is not possible without a Javascript plugin.
Answer the question
In order to leave comments, you need to log in
document.addEventListener('deviceready', function() {
var exitApp = false, intval = setInterval(function (){exitApp = false;}, 1000);
document.addEventListener("backbutton", function (e){
e.preventDefault();
if (exitApp) {
clearInterval(intval)
(navigator.app && navigator.app.exitApp()) || (device && device.exitApp())
}
else {
exitApp = true
history.back(1);
}
}, false);
}, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question