轉---JS 擷取滑鼠左右鍵

來源:互聯網
上載者:User

標籤:blog   http   io   ar   sp   art   on   cti   log   

原文:http://blog.csdn.net/mine3333/article/details/7291557

 

function test() 

alert(event.x+" "+event.y); 
alert(event.button); 

/*右鍵菜單不顯示*/ 
document.oncontextmenu=function() 

return false; 

/*document.onmousedown=function() 

if(event.button==1) 
{alert("left")} 
if(event.button==2) 
{alert("right")} 
}*/ 
document.onkeydown=function() 

alert(event.keyCode); 

</script> 

event.x 滑鼠橫軸 
event.y 滑鼠縱軸 
event.keycode 鍵盤值 
events.button==0 預設。沒有按任何按鈕。 
events.button==1 滑鼠左鍵 
events.button==2 滑鼠右鍵 
events.button==3 滑鼠左右鍵同步選取 
events.button==4 滑鼠中鍵 
events.button==5 滑鼠左鍵和中鍵同步選取 
events.button==6 滑鼠右鍵和中鍵同步選取 
events.button==7 所有三個鍵都按下

轉---JS 擷取滑鼠左右鍵

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.