Day-21 KeyBoard Action

So Eun Ahn·2021년 1월 28일
0

JavaScript

목록 보기
24/26

keydown

only triggers soon as when fingers press down the key

keypress

only triggers action when fingers are continuously on the key

keyup

only triggers action when lift figers off keyboard

document.addEventListner('keydown',function(){});
document.addEventListner('keypress',function(){});
document.addEventListner('keyup',function(){});
  if (e.key === 'Escape' && !modal.classList.contains('hidden')) {
    //if modal class does not contains hidden class close the modal (inverted boolean by using '!')
    closeModal();
  }
//같은 기능을함
if (e.key === 'Escape') {
if (!modal.classList.contains('hidden')) {
  closeModal();
  }  }

profile
오늘도 새로운 도전을 한다

0개의 댓글