- From: Alastair Campbell <acampbell@nomensa.com>
- Date: Fri, 24 Aug 2018 10:10:15 +0000
- To: Detlev Fischer <detlev.fischer@testkreis.de>, WCAG group <w3c-wai-gl@w3.org>
Received on Friday, 24 August 2018 10:10:41 UTC
Hi Detlev, > I am just wondering what the most elegant way would be to implement closing via pressing ESC to close whatever popup menu or custom tool tip happens to be open on a page A good resource for this type of thing is Heydon’s inclusive design components, e.g: https://inclusive-components.design/tooltips-toggletips/ Includes: // Remove toggletip on ESC toggletip.addEventListener('keydown', function(e) { if ((e.keyCode || e.which) === 27) liveRegion.innerHTML = ''; }); The code within the if-statement will depend on how the pop-over was instantiated in the first place, but you get the idea. I *think* that if you’ve registered that type of event on an element, even if you have more than one open, pressing esc will close every instance which has that event registered. However, worth a test or discussion with a JS expert. Cheers, -Alastair
Received on Friday, 24 August 2018 10:10:41 UTC