event.which

· 8년 전 · 1466

event.which


설명 : 키 또는 마우스 이벤트의 경우이 특성은 눌린 특정 키 또는 단추를 나타냅니다.



event.which속성을 정규화 event.keyCode하고 event.charCode. event.which키보드 키 입력 을 감시 하는 것이 좋습니다 . 자세한 내용 은 MDN의 event.charCode를 참조하십시오 .


event.which또한 버튼 누름 ( mousedown및 mouseup이벤트)을 표준화 하고 , 1왼쪽 버튼, 2중간 버튼 및 3오른쪽 버튼을 보고 합니다 . event.which대신에 사용하십시오 event.button.


예 :

어떤 열쇠가 우울했는지 기록하십시오.


<!doctype html>

<html lang="en">

<head>

  <meta charset="utf-8">

  <title>event.which demo</title>

  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>

</head>

<body>

 

<input id="whichkey" value="type something">

<div id="log"></div>

 

<script>

$( "#whichkey" ).on( "keydown", function( event ) {

  $( "#log" ).html( event.type + ": " +  event.which );

});

</script>

 

</body>

</html>

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 8년 전 조회 1,782
jQuery 8년 전 조회 2,017
jQuery 8년 전 조회 1,553
jQuery 8년 전 조회 1,488
jQuery 8년 전 조회 1,580
jQuery
[jQuery]
8년 전 조회 1,465
jQuery 8년 전 조회 1,592
jQuery 8년 전 조회 1,641
jQuery 8년 전 조회 1,658
jQuery 8년 전 조회 1,840
jQuery 8년 전 조회 1,772
jQuery 8년 전 조회 1,636
jQuery 8년 전 조회 1,706
jQuery 8년 전 조회 1,502
jQuery
[jQuery]
8년 전 조회 1,467
jQuery
[jQuery]
8년 전 조회 1,668
jQuery 8년 전 조회 1,555
jQuery 8년 전 조회 1,252
jQuery 8년 전 조회 1,627
jQuery 8년 전 조회 1,371
jQuery 8년 전 조회 1,613
jQuery 8년 전 조회 2,019
jQuery 8년 전 조회 1,993
jQuery 8년 전 조회 1,564
jQuery 8년 전 조회 1,622
jQuery 8년 전 조회 2,018
jQuery
[jQuery]
8년 전 조회 1,519
jQuery
[jQuery]
8년 전 조회 1,437
jQuery 8년 전 조회 2,237
jQuery 8년 전 조회 3,666
🐛 버그신고