File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
10 - Hold Shift and Check Checkboxes Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 104104 </ div >
105105
106106< script >
107+ let shiftPressing = 0 ;
108+ let prevIdx = [ 0 , 0 ] ;
109+
110+ window . addEventListener ( 'keydown' , e => {
111+ if ( e . keyCode === 16 ) {
112+ shiftPressing = 1 ;
113+ }
114+ } ) ;
115+ window . addEventListener ( 'keyup' , e => {
116+ if ( e . keyCode === 16 ) {
117+ shiftPressing = 0 ;
118+ }
119+ } ) ;
120+
121+ [ ...document . querySelectorAll ( 'input[type="checkbox"]' ) ] . forEach ( ( ele , index ) => {
122+ ele . addEventListener ( 'change' , function ( e ) {
123+ if ( this . checked ) {
124+ prevIdx . shift ( ) ;
125+ prevIdx . push ( index ) ;
126+ }
127+ if ( this . checked && shiftPressing ) {
128+ [ ...document . querySelectorAll ( 'input[type="checkbox"]' ) ] . forEach ( ( el , idx ) => {
129+ if ( ( idx <= prevIdx [ 1 ] && idx >= prevIdx [ 0 ] ) || ( idx >= prevIdx [ 1 ] && idx <= prevIdx [ 0 ] ) ) {
130+ el . checked = true ;
131+ }
132+ } )
133+ }
134+ } )
135+ } )
107136</ script >
108137</ body >
109138</ html >
Original file line number Diff line number Diff line change 13137 . [x] ~~ Array Cardio, Day 2~~
14148 . [x] ~~ Fun with HTML5 Canvas~~
15159 . [x] ~~ Dev Tools Domination~~
16- 10 . [ ] Hold Shift and Check Checkboxes
16+ 10 . [x] ~~ Hold Shift and Check Checkboxes~~
171711 . [ ] Custom Video Player
181812 . [ ] Key Sequence Detection
191913 . [ ] Slide in on Scroll
You can’t perform that action at this time.
0 commit comments