tristen / hoverintent

:mouse: Fire mouse events when a user intends it
https://tristen.ca/hoverintent/
MIT License
331 stars 54 forks source link

Accessibility: close/cancel when escape is pressed #27

Closed mollylentz closed 5 years ago

mollylentz commented 5 years ago

If anyone has figured out a way to make this work, that would be awesome. For accessibility reasons, you should be able to hit the escape key in order to hide the bit that is being revealed on hover. I have yet to figure out an elegant way to do this.

bronzehedwick commented 5 years ago

@mollylentz Can you use the handleFocus setting to add a callback for onOver/onOut, then add/remove the escape key listener there, respectively, and finally hide then menu?

mollylentz commented 5 years ago

That completely worked! I must have really been hitting a wall yesterday. Thank you so very much.