I’d look for an up key event, rather than a down event, with onKeyUp.
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
// ........
return true;
}
return super.onKeyUp(keyCode, event);
}
We return true because we’re handling the event; return false if you want the system to handle the event too.
You can do all of this in your Activity instance too because Activity is a known indirect subclass of KeyEvent.