Close menu using escape key
Closed this issue · 3 comments
Is there a way to close the menu using the escape key? I try to optimize a page concerning the accessibility of the menu and it would be pretty awesome to be able to close the menu by pressing escape.
The extension is aimed at mobile devices where there is no escape key. You may try to use the available API:
if (escape_key_is_pressed) {
$('#mobile-menu-123').data('plugin_mobileMenu').hideMenu();
}
Thanks a lot for the tip. Where shoul I insert this snippet? In the nav_template?
I just put it in the page layout in the "own javascript section".
$(document).keyup(function(e) { if (e.keyCode == 27) { $('#mobile-menu-XX').data('plugin_mobileMenu').hideMenu(); } });
Key code 27 is the Escape-key.
By the way: My accessibility expert told me that it is not only useful for desktop use, but also for the mobile use, because people who rely on accessibility have other tools to navigate on a website, even on a mobile device. You may consider to put this option in the module, even if somebody uses it as a normal desktop menu, as I do sometimes.
Cheers,
operatorone