android平台菜单返回键监听
//声明
void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);
//实现
//按键控制(检测onKeyReleased有反应) auto listener = EventListenerKeyboard::create(); listener->onKeyReleased = CC_CALLBACK_2(MenuLayer::onKeyReleased, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); void MenuLayer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event) { switch(keyCode) { //监听返回键 case EventKeyboard::KeyCode::KEY_ESCAPE: Director::getInstance()->end(); break; //监听menu键 case EventKeyboard::KeyCode::KEY_MENU: break; } }