728x90
keyup : ๋๋ฅธ ํค์์ ์์ ๋ ๋ ์คํ.
$("#์์ด๋๋ช
").keyup(function(e){
if(e.keyCode == 13){
// ํธ์ถํ ํจ์๋ ๊ธฐ๋ฅ ์์ฑ
}
});
$("#์์ด๋๋ช
").keyup(function(e){
if(e.which == 13){
// ํธ์ถํ ํจ์๋ ๊ธฐ๋ฅ ์์ฑ
}
});
keydown : ํค๋ณด๋์ ์ด๋ ํ ํค๊ฐ ๋๋ ค๋ ์คํ
$("input[name=name๋ช
]").keydown(function(e) {
if(e.keyCode == 13){
// ํธ์ถํ ํจ์๋ ๊ธฐ๋ฅ ์์ฑ
}
});
$("input[name=name๋ช
]").keydown(function(e) {
if(e.which == 13){
// ํธ์ถํ ํจ์๋ ๊ธฐ๋ฅ ์์ฑ
}
});
Key | Code | Key | Code | Key | Code |
backspace | 8 | e | 69 | ์ซ์ํจ๋ 8 | 104 |
tab | 9 | f | 70 | ์ซ์ํจ๋ 9 | 105 |
enter | 13 | g | 71 | ์ซ์ํจ๋ * | 106 |
shift | 16 | h | 72 | ์ซ์ํจ๋ + | 107 |
ctrl | 17 | i | 73 | ์ซ์ํจ๋ - | 109 |
alt | 18 | j | 74 | ์ซ์ํจ๋ . | 110 |
pause/break | 19 | k | 75 | ์ซ์ํจ๋ / | 111 |
caps lock | 20 | l | 76 | f1 | 112 |
ESC | 27 | m | 77 | f2 | 113 |
page up | 33 | n | 78 | f3 | 114 |
page down | 34 | o | 79 | f4 | 115 |
end | 35 | p | 80 | f5 | 116 |
home | 36 | q | 81 | f6 | 117 |
left arrow | 37 | r | 82 | f7 | 118 |
up arrow | 38 | s | 83 | f8 | 119 |
right arrow | 39 | t | 84 | f9 | 120 |
down arrow | 40 | u | 85 | f10 | 121 |
insert | 45 | v | 86 | f11 | 122 |
delete | 46 | w | 87 | f12 | 123 |
0 | 48 | x | 88 | num lock | 144 |
1 | 49 | y | 89 | scroll lock | 145 |
2 | 50 | z | 90 | ; | 186 |
3 | 51 | left window key | 91 | = | 187 |
4 | 52 | right window key | 92 | , | 188 |
5 | 53 | select key | 93 | - | 189 |
6 | 54 | ์ซ์ํจ๋ 0 | 96 | . | 190 |
7 | 55 | ์ซ์ํจ๋ 1 | 97 | / | 191 |
8 | 56 | ์ซ์ํจ๋ 2 | 98 | ` | 192 |
9 | 57 | ์ซ์ํจ๋ 3 | 99 | [ | 219 |
a | 65 | ์ซ์ํจ๋ 4 | 100 | (๋ฐฑ์ฌ๋์) | 220 |
b | 66 | ์ซ์ํจ๋ 5 | 101 | ] | 221 |
c | 67 | ์ซ์ํจ๋ 6 | 102 | ‘ | 222 |
d | 68 | ์ซ์ํจ๋ 7 | 103 |
* ์ฐธ๊ณ : ์ด์ ์์ฑ( .keyCode๋ฐ .which)์ ๋ ์ด์ ์ฌ์ฉ๋์ง ์๋๋ค. *
* e.key === "Enter" ๋ฅผ ์ฌ์ฉํ์!
$(document).keyup(function(e) {
// focus ๋๊ณ enter๋๋ ์ ๊ฒฝ์ฐ
if ($(".ํด๋์ค๋ช
").is(":focus") && e.key == "Enter") {
// ํธ์ถํ ํจ์๋ ๊ธฐ๋ฅ ์์ฑ
}
});
$(document).keyup(function (e) {
// focus ๋๊ณ enter๋๋ ์ ๊ฒฝ์ฐ
if ($(".input1:focus") && (e.key == "Enter")) {
// ํธ์ถํ ํจ์๋ ๊ธฐ๋ฅ ์์ฑ
}
});
'js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[jQuery]๋์ append ํ .find() .remove() (0) | 2021.11.19 |
---|---|
[JavaScript] div setTimeout display block/none (0) | 2021.11.12 |
[JavaScript] input Box ์๋ submit ๋ง๋ ๋ฐฉ๋ฒ 3๊ฐ์ง (0) | 2021.11.04 |
[jQuery] ํ์ผ ์ ๋ก๋ input type = 'file' ๋ค์ค์ผ๋ก ์์ฑํ๊ธฐ (2) | 2021.10.26 |
[jQuery] ๋์ ์ถ๊ฐ๋ append์ click event ์ฒ๋ฆฌ (0) | 2021.10.26 |