keydown event in drop down list

前端 未结 12 1596
日久生厌
日久生厌 2020-12-07 00:24

I am trying to create a Drop down list, that when a user holds the SHIFT key, it will select the same index on all other drop down lists.

Currently, I am doing the f

12条回答
  •  暖寄归人
    2020-12-07 01:16

    Hop this thing help you out.. :)

     var onkeydown = (function (ev) {
          var key;
          var isShift;
          if (window.event) {
            key = window.event.keyCode;
            isShift = window.event.shiftKey ? true : false;
          } else {
            key = ev.which;
            isShift = ev.shiftKey ? true : false;
          }
          if ( isShift ) {
            switch (key) {
              case 16: // ignore shift key
                break;
              default:
                alert(key);
                // do stuff here?
                break;
            }
          }
        });
    

提交回复
热议问题