event.which

· 8년 전 · 1463

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,781
jQuery 8년 전 조회 2,015
jQuery 8년 전 조회 1,552
jQuery 8년 전 조회 1,487
jQuery 8년 전 조회 1,579
jQuery
[jQuery]
8년 전 조회 1,462
jQuery 8년 전 조회 1,591
jQuery 8년 전 조회 1,638
jQuery 8년 전 조회 1,657
jQuery 8년 전 조회 1,837
jQuery 8년 전 조회 1,770
jQuery 8년 전 조회 1,632
jQuery 8년 전 조회 1,703
jQuery 8년 전 조회 1,501
jQuery
[jQuery]
8년 전 조회 1,464
jQuery
[jQuery]
8년 전 조회 1,665
jQuery 8년 전 조회 1,553
jQuery 8년 전 조회 1,250
jQuery 8년 전 조회 1,625
jQuery 8년 전 조회 1,368
jQuery 8년 전 조회 1,612
jQuery 8년 전 조회 2,017
jQuery 8년 전 조회 1,990
jQuery 8년 전 조회 1,561
jQuery 8년 전 조회 1,618
jQuery 8년 전 조회 2,014
jQuery
[jQuery]
8년 전 조회 1,516
jQuery
[jQuery]
8년 전 조회 1,434
jQuery 8년 전 조회 2,234
jQuery 8년 전 조회 3,663
🐛 버그신고