event.which

· 8년 전 · 1470

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,789
jQuery 8년 전 조회 2,022
jQuery 8년 전 조회 1,558
jQuery 8년 전 조회 1,490
jQuery 8년 전 조회 1,584
jQuery
[jQuery]
8년 전 조회 1,469
jQuery 8년 전 조회 1,598
jQuery 8년 전 조회 1,645
jQuery 8년 전 조회 1,663
jQuery 8년 전 조회 1,847
jQuery 8년 전 조회 1,777
jQuery 8년 전 조회 1,640
jQuery 8년 전 조회 1,713
jQuery 8년 전 조회 1,510
jQuery
[jQuery]
8년 전 조회 1,471
jQuery
[jQuery]
8년 전 조회 1,674
jQuery 8년 전 조회 1,559
jQuery 8년 전 조회 1,256
jQuery 8년 전 조회 1,634
jQuery 8년 전 조회 1,376
jQuery 8년 전 조회 1,619
jQuery 8년 전 조회 2,024
jQuery 8년 전 조회 1,995
jQuery 8년 전 조회 1,568
jQuery 8년 전 조회 1,627
jQuery 8년 전 조회 2,022
jQuery
[jQuery]
8년 전 조회 1,524
jQuery
[jQuery]
8년 전 조회 1,439
jQuery 8년 전 조회 2,242
jQuery 8년 전 조회 3,670
🐛 버그신고