Skip to content

Commit

Permalink
close nav on escape key press
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshvdw committed May 3, 2024
1 parent 58d0b16 commit b952cb0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ if (document.readyState !== "loading") {
window.addEventListener("load", onReady);
document.addEventListener("DOMContentLoaded", onLoading);
}

// close menu on escape key press
const handleEscape = (e) => {
if (e.key === "Escape") {
const closeBtn = document.querySelector(".burger-close-icon");
const hamburgerMenu = document.querySelector(".hamburger-box");
if (hamburgerMenu.style.opacity == 0) {
closeBtn.click();
}
}
};
window.addEventListener("keydown", handleEscape);
9 changes: 9 additions & 0 deletions dist/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/app.js.map

Large diffs are not rendered by default.

0 comments on commit b952cb0

Please sign in to comment.