Closing modal by pressing the "esc" key

Hi,

Is there any simple script that allows me to assign the ".close-modal"button to the “esc” key on the keyboard?

Thank you,
G


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

1 Like

Link to custom code solution below. Although I do think an out-of-the-box modal component that’s accessible is really missing from Webflow. Such a common element!
https://webflow.com/website/Closing-modal-window-on-the-ESC-button-99ui8

1 Like

Meanwhile published by webflow:

Further solution by finsweet

I actually found Finsweet’s accessible modal component first, ha.

I prefer using a Webflow developer’s solution (for no good reason). However, their custom code seems to break/override the smooth fade out close interaction. :confounded: