Набросал свой код - https://jsfiddle.net/djkcsvL2/
Подскажите пожалуйста, почему не смотря на условие keyPress === "Enter"
форма появляется при нажатии на любую кнопку и как это можно исправить.
Заранее спасибо
popupForm = document.querySelector('.popup-form-section');
const openPopupForm = event =>{
const target = event.target;
const keyPress = event.key;
if (keyPress === "Enter" || openPopupForm) {
popupForm.style.display = 'block';
}
popupForm.addEventListener('click', closePopupForm);
document.removeEventListener("keydown", openPopupForm);
};
function closePopupForm(){
console.log("Закрыть");
};
document.addEventListener("keydown", openPopupForm);
<div class="popup-form-section">
</div>
<style>
.popup-form-section{
position: fixed;
top:0;
left:0;
background: #000;
width: 100%;
height: 100%;
display: none;
}
</style>