menu button handling from immortaldevs