I am currently working on a status bar app on macOS, After the user opens the bar menu by press shortcut key and entered a submenu, I want to use the ESC key to collapse a submenu, but I can't found a solution to collapse a submenu programmatically anywhere.
Selecting any option will automatically load the page