escape images with escape
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s

This commit is contained in:
ebby 2026-10-06 20:44:57 +02:00
parent bb6c8ad993
commit 0a18da80c2

View file

@ -2,6 +2,14 @@ const backdrop = document.querySelector("#image-backdrop");
const preview = document.querySelector("#image-preview");
if (backdrop instanceof HTMLElement && preview instanceof HTMLImageElement) {
document.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
backdrop.hidden = true;
document.body.style.overflow = "";
}
});
document.addEventListener("click", (event) => {
if (!(event.target instanceof Element)) return;