How to Close a Popup with the Esc Key in Webflow
Learn how to close a popup or modal in Webflow with the Esc key using a JavaScript keydown listener.
In this tutorial, Sandro, cofounder of the Gemeos Webflow agency, shows you how to close a popup or modal in Webflow with the Escape key.
Example
The script
Add this script in the Before </body> tag of your page. Replace .modal-overlay with your popup class.
Adapt it for multiple popups
To close all open popups at once with Escape:
Conclusion
One line of code that significantly improves keyboard accessibility. See also: create a native modal in Webflow.
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.








.avif)






