gpt4 book ai didi

javascript - 如何使用 Javascript 检查当前鼠标按钮状态

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:26:59 24 4
gpt4 key购买 nike

<分区>

我希望鼠标处于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 值

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com