我想要鼠标处于Down 状态或up 状态
document.onmousemove = mouseMove;
document.onmousedown = mouseDown;
document.onmouseup = mouseUp;
function mouseMove(ev) {
mouseState="";
//How can I know the state button of mouse button from here
if(mouseState=='down') {
console.log('mouse down state')
}
if(mouseState=='up') {
console.log('mouse up state')
}
}
function mouseDown(ev) {
console.log('Down State you can now start dragging');
//do not write any code here in this function
}
function mouseUp(ev) {
console.log('up state you cannot drag now because you are not holding your mouse')
//do not write any code here in this function
}
当我移动鼠标时,程序现在应该在控制台上显示所需的 mouseState 值