Select multiple HTML table rows with Ctrl+click and Shift+click

前端 未结 6 1265
再見小時候
再見小時候 2021-01-31 20:20

Demo

I want to select multiple rows using Windows Shift and Ctrl keys, like multiple folder selection in Windows.

From table of selected ro

6条回答
  •  醉酒成梦
    2021-01-31 21:22

    Check this example:

    JSFiddle: Highlight list with shift and ctrl

    Part of the code:

    switch(e.type) {
        case "keydown" :
            console.log('k_down');
            keysPressed.push(e.keyCode);
            break;
        case "keyup" :
            console.log('k_up');
            var idx = keysPressed.indexOf(e.keyCode);
            if (idx >= 0)
                keysPressed.splice(idx, 1);
            break;
    }
    

    Sources could be found here: Source files github

提交回复
热议问题