event listener for esc keypress

This commit is contained in:
Berkowitz
2019-05-10 15:01:48 -04:00
parent 70662fee62
commit 0f82f4865f
3 changed files with 23 additions and 1 deletions

View File

@@ -229,6 +229,17 @@ mailgoInit = () => {
},
false
);
// allow the escape key to hide the modal
mailgo.addEventListener(
"keydown",
event => {
if (event.keyCode === 27) {
mailgo.nextElementSibling.classList.remove("is-active");
}
},
false
);
// every click outside the modal will hide the modal
modalBackground.addEventListener(