1) keyup: happens when we lift or finger off the keyboard or off the key
키보드에서 손을 땠을 때
2) keypress: when we keep our finger on a certain key
키보드를 눌렀을 때, 누르고 있을 때 계속 실행
3) keydown: as soon as we just press down the key. so ususally that is the one that we use
키보드를 눌렀을 때, 누르고 있을 떄 한번 실행 -> 대부분 keydown 사용
document.addEventListener('keydown', function (e) {
// console.log(e.key);
if (e.key === 'Escape' && !modal.classList.contains('hidden')) {
closeModal();
}
});
'자바스크립트' 카테고리의 다른 글
[JavaScript] classList.toggle 기능 (0) | 2020.12.04 |
---|---|
[JavaScript] HTML structure 자동 설정 (vs code) (0) | 2020.12.04 |
[JavaScript] function, function() 차이 (0) | 2020.12.04 |
[JavaScript] value VS. textContent (0) | 2020.12.04 |
[JavaScript] 55. Setting up prettier and VS code (console.log 단축키) (0) | 2020.12.04 |