So, I know that this sounds like a duplicate, but it is not (or, if so, the accepted answer to everything I can find does not work the way I need it). The problem is this:
I write in HTML5 using jQuery, I need to make a grid that allows multi-select with control and shift. I have this logical work, but whenever you switch, it selects the text in the grid. I want to prevent this choice, but there is a critical difference between these and other issues that I found: I want the text selection to work at any other time.
Repeat: I want to disable text selection using shift WITHOUT disabling all text selection for specified elements. Does anyone know how I can do this?
- EDIT -
The following (in the constructor for the grid) solved this for me. As the interlocutor suggested, I declared a class for non-selectivity.
this.gridBody = $("#userGrid"); var handleKeydown = function(e) { e = e || window.event; var keyPressed = e.keyCode || e.which; if (keyPressed == keys.shift) { e.data.gridBody.addClass("unselectable"); } }; var handleKeyup = function(e) { e = e || window.event; var keyPressed = e.keyCode || e.which; if (keyPressed == keys.shift) { e.data.gridBody.removeClass("unselectable"); } }; $(document).on('keydown', this, handleKeydown); $(document).on('keyup', this, handleKeyup);
javascript jquery html5 css3 shift
Adam mccormick
source share