0

For example, I am able to prevent the back key from exiting the app using this function:

function onDeviceReady(){
    document.addEventListener("backbutton", onBackKeyDown, false);
}
function onBackKeyDown(){
    alert('back');
    return false;
}

How can I do the same for the over two navigation keys? I used a plugin to hide the whole navigation bar, but it comes back whenever the keyboard comes up.

Thanks in advance.

2 Answers2

2

How can I do the same for the over two navigation keys?

You don't, from an app. You have no ability to control the behavior of HOME or RECENTS.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for your reply. How is it that I can prevent the "back" key from leaving the app but not the others? – Rocky Racoon Oct 08 '17 at 11:19
  • @RockyRacoon: Google wanted developers to have some flexibility over BACK behavior, though there are plenty of apps that do so and really irritate users. For security reasons, users need to be able to exit apps, and to do, they primarily use HOME and RECENTS. – CommonsWare Oct 08 '17 at 11:28
0

This Code Work perfectly in my project.

function onLoadback() {

    document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {

    document.addEventListener("backbutton", onBackKeyDown, false);

}
adsfour1
  • 1
  • 1