Enable using escape key to close navigation toggle

This commit is contained in:
Helen Chong 2024-06-08 00:43:19 +08:00
parent fb4515acc5
commit a7c2bf8f29
1 changed files with 7 additions and 0 deletions

View File

@ -111,4 +111,11 @@
} }
navbarToggle.addEventListener("click", toggleNavigation); navbarToggle.addEventListener("click", toggleNavigation);
window.addEventListener("keyup", (e) => {
if (e.key === "Escape") {
navbarToggle.focus();
closeNavigation();
}
});
</script> </script>