Superfish: How to hide sub-menus (3rd level) on escape key and having no effect to 2nd level menu

Superfish: How to hide sub-menus (3rd level) on escape key and having no effect to 2nd level menu

Hi Joel Birch and all other experts,

I am having some issue with superfish menu. It works great on most of the circumstances. but it is unable to handle escape key behavior on multi-level menus.

Explanation:

Menu items on top level (level one) : L1 L2 L3 L4
Menu items on 2nd level: L1 -> L11 L12 L13
                                    L2 -> L21 L22 L23
Menu items on 3rd level: L12 -> L121 L122
                                    L21 -> L211 L212 L213

Issue: Need to handle escape key

When i pressed escape on one of(L121,L122,L211,L212,L213) the 3rd level items, I am using the following code:

$(document).keydown(function(e) {
    var $$ = $(this);
    // ESCAPE key pressed
    if (e.keyCode == 27) {
      
        $$.hideSuperfishUl();
    }
    });

The above triggers the close of entire menu structure. but what i want is, when i close 3rd level menu item, only that <ul> should close leaving no effect for 2nd level/1st level items. i.e,.

L121 can be opened only when hovered/focused on L12. So when i press escape on L121 -> L12 should not be closed. it should remain as is.

I hope you understand my problem. If i am not clear please let me know.

You can contact me at: hallowbestboy@gmail.com

Thanks and Regards,

Best Boy.