Skip to content

Commit

Permalink
close drawer on Escape key press when it's open
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdikhashan committed May 5, 2024
1 parent a3faeb6 commit 6852133
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ document.addEventListener("DOMContentLoaded", () => {
}
})

document.addEventListener("keydown", (event) => {
const drawerIsOpen = drawer.classList.contains("drawer-open")
if (event.key === "Escape" && drawerIsOpen) {
closeDrawer()
}
})

const openDraw = () => {
drawer.classList.add("drawer-open");
document.body.style.overflow = "hidden";
Expand Down

0 comments on commit 6852133

Please sign in to comment.