auto listener = EventListenerKeyboard::create();
listener->onKeyReleased = [](EventKeyboard::KeyCode code,Event* event){
switch (code)
{
case EventKeyboard::KeyCode::KEY_BACK: //回退键
Director::getInstance()->end(); break;
case EventKeyboard::KeyCode::KEY_MENU: //菜单键
Director::getInstance()->end(); break;
default:
break;
}
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraPHPriority(listener,this);