How can I bind a global call back to an phy button?

how can I bind a global call back to an phy button?

I have many display pages in my project, My gui have no back button on the display,
I have a physical button used to as go back ,
so how can I set the goback event_cb to this physical button just once?

Now when I make a new page , add a obj like list, I have to set list event cb to process the physical call back

Just like Global Hotkey in pc?

I suggest using the template to give us context.

But basically, make a function to change_the_page and pass it as callback to the button handler.

page A
--------page A.1
----------------page A.1.1

how can I bind the fun call to an lv_obj just once, Now on every page(A, A.1 ,A.1.1) for every obj , i bind the same call and process the esc_event, and define like follow

#define PAGE_EVENT_CB_BEGIN(name)  void name(lv_obj_t * obj, lv_event_t e){\
    if (e == LV_EVENT_CANCEL || (e == LV_EVENT_KEY && (*(uint32_t*)lv_event_get_data() == LV_KEY_ESC) ))\
    {\
        printf("del by page class\n");\
        lvPage::close();\
        return;\
    }\

#define PAGE_EVENT_CB_END() }

and then use like follow , apnConfigRun is a fun bind to every obj on the page like A.1.1

PAGE_EVENT_CB_BEGIN(apnConfigRun)
    {
        if (obj != kb) {
            lv_group_focus_obj(kb);
        } else {
    }
PAGE_EVENT_CB_END()

and every fun call I have to use PAGE_EVENT_CB_BEGIN