Android hardware menu button

Hi guys

I’m trying to open the side menu when the hardware menu button is pressed.
The example in Open side menu on hardware menu button (Android) doesn’t work for me.

Any help?

Thanks

The Cordova team removed support for the menu button in their libraries a while ago, as discovered here:

Thanks revie for the link.

I’d rather not monkey patch the Cordova library, the post is also from a year ago, is there a fix since then?

Nope. That’s your only option, unfortunately.

Ok, that’s sad news :confused:

I have your solution!

You need to overwrite the android methods!

This is my code:

$ionicPlatform.ready(function() {
navigator.app.overrideButton(“menubutton”, true);
document.addEventListener(“menubutton”, onMenuKeyDown, false);

function onMenuKeyDown() {
    console.log("Menu");
}

});

2 Likes

Brilliant, this works! :grinning: