3
I need to move the <input type="range">
only when the CTRL and the left mouse click are pressed. I managed to do this with this code:
$(document).keydown(function(e) {
if (e.which == 17) {
document.onmousedown = function() {
document.querySelector('body').addEventListener('mousemove', ouvinteBrilho, false);
return false;
}
}
})
The problem is that even after releasing the CTRL it keeps moving if I keep holding the mouse click. I have tried to do it this way and without success:
$(document).keyup(function(e) {
if (e.which == 17) {
document.querySelector('body').removeEventListener('mousemove', ouvinteBrilho);
}
})
Or:
document.onmouseup = function() {
document.querySelector('body').removeEventListener('mousemove', ouvinteBrilho);
return false;
}
Edit: When I only do it with CTRL works perfectly:
$(document).keydown(function(e) {
if (e.which == 17) {
document.querySelector('body').addEventListener('mousemove', ouvinteBrilho, false);
}
})
$(document).keyup(function(e) {
if (e.which == 17) {
document.querySelector('body').removeEventListener('mousemove', ouvinteBrilho);
}
})