• 회원가입
  • 로그인
  • 구글아이디로 로그인

[js] JS - ctrlKey, altKey, shiftKey 속성 - Ctrl키, Alt키, Shift키 눌림여부 반환. (= 컨트롤키코드, 알트키코드, 시프트키코드)

 

 

$('selector').bind('click', function(event){ 

    if(event.ctrlKey) {

      if (event.ctrlLeft) {

        console.log('ctrl-left'); 

      }

      else {

        console.log('ctrl-right');

      }

    }

    if(event.altKey) {

      if (event.altLeft) {

        console.log('alt-left'); 

      }

      else {

        console.log('alt-right');

      }

    }

    if(event.shiftKey) {

      if (event.shiftLeft) {

        console.log('shift-left'); 

      }

      else

      {

        console.log('shift-right');

      }

    }

  });

 

애드프로 님 (190922) https://sir.kr/qa/324368

 

방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
게시물이 없습니다.
목록
찾아주셔서 감사합니다. Since 2012