๐Ÿงท ์ž์ฃผ ์“ฐ๋Š” Event ์ข…๋ฅ˜ (์ด๋ฒคํŠธ ํƒ€์ž…)

์ด๋ฒคํŠธ๋Š” "click", "keydown" ๊ฐ™์€ ๋ฌธ์ž์—ด๋กœ ๊ตฌ๋ถ„๋ผ.

๐Ÿ”˜ ๋งˆ์šฐ์Šค ์ด๋ฒคํŠธ

์ด๋ฒคํŠธ ์ด๋ฆ„ ์„ค๋ช…
click ํด๋ฆญํ–ˆ์„ ๋•Œ
dblclick ๋”๋ธ”ํด๋ฆญ
mousedown ๋งˆ์šฐ์Šค ๋ฒ„ํŠผ ๋ˆ„๋ฅผ ๋•Œ
mouseup ๋งˆ์šฐ์Šค ๋ฒ„ํŠผ ๋—„ ๋•Œ
mousemove ๋งˆ์šฐ์Šค๊ฐ€ ์›€์ง์ผ ๋•Œ
mouseenter ์š”์†Œ์— ๋งˆ์šฐ์Šค ์ง„์ž… (๋ฒ„๋ธ” ์•ˆ ๋จ)
mouseleave ์š”์†Œ์—์„œ ๋งˆ์šฐ์Šค ๋‚˜๊ฐ (๋ฒ„๋ธ” ์•ˆ ๋จ)
mouseover ์š”์†Œ ์œ„์— ๋งˆ์šฐ์Šค ์˜ฌ๋ฆผ
mouseout ์š”์†Œ ๋ฐ–์œผ๋กœ ๋งˆ์šฐ์Šค ๋‚˜๊ฐ
contextmenu ์šฐํด๋ฆญ ๋ฉ”๋‰ด

โŒจ๏ธ ํ‚ค๋ณด๋“œ ์ด๋ฒคํŠธ

์ด๋ฒคํŠธ ์ด๋ฆ„ ์„ค๋ช…
keydown ํ‚ค ๋ˆ„๋ฆ„
keyup ํ‚ค ๋—Œ
keypress (๊ฑฐ์˜ ์•ˆ ์”€, ์ด์ œ deprecated๋จ)

๐Ÿงพ ํผ ์ด๋ฒคํŠธ

์ด๋ฒคํŠธ ์ด๋ฆ„ ์„ค๋ช…
submit ํผ ์ œ์ถœ
change <input>, <select>, <textarea> ๊ฐ’ ๋ฐ”๋€” ๋•Œ
input input ์š”์†Œ์— ์ž…๋ ฅ์ด ์žˆ์„ ๋•Œ (์‹ค์‹œ๊ฐ„)
focus ํฌ์ปค์Šค ๋์„ ๋•Œ
blur ํฌ์ปค์Šค๊ฐ€ ๋น ์งˆ ๋•Œ

๐Ÿ“ฑ ํ„ฐ์น˜ ์ด๋ฒคํŠธ (๋ชจ๋ฐ”์ผ)

์ด๋ฒคํŠธ ์ด๋ฆ„ ์„ค๋ช…
touchstart ํ„ฐ์น˜ ์‹œ์ž‘
touchmove ํ„ฐ์น˜ ์ค‘ ์›€์ง์ž„
touchend ํ„ฐ์น˜ ๋๋‚จ
touchcancel ํ„ฐ์น˜ ์ทจ์†Œ

๐Ÿ“ฆ ๊ธฐํƒ€ ์ด๋ฒคํŠธ

์ด๋ฒคํŠธ ์ด๋ฆ„ ์„ค๋ช…
load ํŽ˜์ด์ง€๋‚˜ ๋ฆฌ์†Œ์Šค ๋กœ๋“œ ์™„๋ฃŒ
resize ์ฐฝ ํฌ๊ธฐ ๋ณ€๊ฒฝ
scroll ์Šคํฌ๋กค๋  ๋•Œ
wheel ๋งˆ์šฐ์Šค ํœ  ๊ตด๋ฆด ๋•Œ
animationend ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋๋‚  ๋•Œ
transitionend CSS ํŠธ๋žœ์ง€์…˜ ๋๋‚  ๋•Œ
drag, drop ๋“œ๋ž˜๊ทธ ๊ด€๋ จ

๐Ÿงฉ addEventListener() ๊ธฐ๋ณธ ๋ฌธ๋ฒ•

element.addEventListener("์ด๋ฒคํŠธ๋ช…", ์ฝœ๋ฐฑํ•จ์ˆ˜, ์˜ต์…˜);

์˜ˆ์‹œ:

button.addEventListener("click", function(e) {
  console.log("Clicked!", e);
});


๐Ÿ“ฆ ์ด๋ฒคํŠธ ๊ฐ์ฒด ์†์„ฑ (event ๋˜๋Š” e๋กœ ๋งŽ์ด ์”€)

์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์•ˆ์—์„œ ์“ฐ๋Š” e ๊ฐ์ฒด๋Š” ๋‹ค์–‘ํ•œ ์ •๋ณด ํฌํ•จํ•ด. ๋Œ€ํ‘œ์ ์œผ๋กœ: