event.which

· 8년 전 · 1484

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,796
jQuery 8년 전 조회 2,042
jQuery 8년 전 조회 1,583
jQuery 8년 전 조회 1,516
jQuery 8년 전 조회 1,597
jQuery
[jQuery]
8년 전 조회 1,472
jQuery 8년 전 조회 1,615
jQuery 8년 전 조회 1,668
jQuery 8년 전 조회 1,680
jQuery 8년 전 조회 1,862
jQuery 8년 전 조회 1,800
jQuery 8년 전 조회 1,659
jQuery 8년 전 조회 1,729
jQuery 8년 전 조회 1,518
jQuery
[jQuery]
8년 전 조회 1,485
jQuery
[jQuery]
8년 전 조회 1,684
jQuery 8년 전 조회 1,576
jQuery 8년 전 조회 1,272
jQuery 8년 전 조회 1,653
jQuery 8년 전 조회 1,386
jQuery 8년 전 조회 1,637
jQuery 8년 전 조회 2,039
jQuery 8년 전 조회 2,017
jQuery 8년 전 조회 1,579
jQuery 8년 전 조회 1,643
jQuery 8년 전 조회 2,037
jQuery
[jQuery]
8년 전 조회 1,535
jQuery
[jQuery]
8년 전 조회 1,454
jQuery 8년 전 조회 2,255
jQuery 8년 전 조회 3,680
🐛 버그신고