Note: this questions is different from How to disable text selection highlighting using CSS?
Before ask I read the discussion history from above question. All works fine, except I can allow CTRL+A
(Select All) only works inside input elments.
That's because I'm deploying my HTML5 app on Desktop and I wish the same behavior from a GUI/Forms application.
What would be the starting point? Try to bind at all elements with keypress
event and observe CTRL + A keyCode
? The disadvantage of this approach would have to be controlling everything and take care on re-renders.
I prefer a CSS solution, but any idea is welcome.
Thanks in advance.
@EDIT: I found this ulgy solution, but working:
$(document).keydown(function(objEvent) {
if (objEvent.ctrlKey) {
if ((objEvent.keyCode === 65) || (objEvent.keyCode == 97)) {
if ($(objEvent.target).not("input").disableTextSelect().length) {
return false;
}
}
}
});