250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- REACT
- concept
- CSS
- blockchain
- express.js
- bitcoin
- solidity
- JavaScript
- Redux
- API
- CLASS
- web
- hardhat
- SSR
- HTML
- useState
- Props
- Interface
- nextJS
- node.js
- typeScript
- error
- evm
- built in object
- middleware
- graphQL
- Ethereum
- tailwindcss
- 삶
- 기준
Archives
- Today
- Total
ReasonJun
javascript : event (handler once, passive, keyboard) 본문
Frontend/Javasciprt
javascript : event (handler once, passive, keyboard)
ReasonJun 2023. 6. 9. 00:10728x90
handler once / passive
// Handler run only once
const parentEl = document.querySelector('.parent');
parentEl.addEventListener(
'click',
(event) => {
console.log('parent');
},
{
once: true,
}
);
// Separation of default behavior and handler execution
// The execution itself may be slow because there are many actions on the webpage, but the user's manipulation of the webpage proceeds smoothly.
parentEl.addEventListener(
'wheel',
() => {
for (let i = 0; i < 10000; i++) {
console.log(i);
}
},
{
passive: true,
}
);
keyboard
// keydown : press key
// keyup : release key
const inputEl = document.querySelector('input');
inputEl.addEventListener('keydown', (event) => {
console.log(event.key);
});
// The following configuration is necessary to prevent double stamping when entering Hangul.
inputEl.addEventListener('keydown', (event) => {
if (event.key === 'Enter' && !event.isComposing) {
console.log(event.isComposing);
console.log(event.target.value);
}
});
728x90
'Frontend > Javasciprt' 카테고리의 다른 글
javascript : set (0) | 2023.06.09 |
---|---|
javascript : event (mouse pointer event, prevent basic work) (0) | 2023.06.09 |
javascript : event (event obj, focus form event) (0) | 2023.06.09 |
javascript : event (delegation, event bubbling) (0) | 2023.06.08 |
javascript : event ( add, remove, dispatch, custom event) (0) | 2023.06.08 |
Comments