document.addEventListener("keydown", openPopupForm);
const openPopupForm = (event) =>{
const target = event.target;
const keyPress = event.key;
event.preventDefault();
if (keyPress === "Enter" || openPopupForm) {
popupForm.style.display = 'block';
}
popupForm.addEventListener('click', closePopupForm);
document.removeEventListener("keydown", openPopupForm);
};
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.block {
/*display: none;*/
}
</style>
</head>
<body>
<div class="block">
<button class="exit">EXIT</button>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.</p>
</div>
<script type="text/javascript">
"use strict";
document.querySelector(".exit").addEventListener("click", (e) => {
e.target.parentElement.style.display = "none";
});
const openPopupForm = (event) =>{
const target = event.target;
const keyPress = event.key;
event.preventDefault();
if (keyPress === "Enter") {
document.querySelector(".block").style.display = 'block';
}
};
document.addEventListener("keydown", openPopupForm);
</script>
</body>
</html>