我想在鼠標的狀態下狀態或了狀態如何檢查當前的鼠標按鈕狀態使用JavaScript
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現在在控制檯上向下或向下移動
此問題與[chrome問題](http://www.pmarks.net/posted_links/chromium_up_down_bug.html)有關。而IE也顯示出同樣的問題。有沒有解決方案 – vusan
我想知道鼠標按鈕的狀態,因爲[this](http://stackoverflow.com/questions/12191743/how-to-know-the-current-state-of-mouse-buttonmouseup-狀態或mousedown狀態)問題。 – vusan