欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS 獲取鼠標(biāo)左右鍵的鍵值方法

 更新時(shí)間:2014年10月11日 17:31:23   投稿:whsnow  
這篇文章主要介紹了JS 獲取鼠標(biāo)左右鍵的鍵值方法,很簡單,但很實(shí)用,特別是在做與用戶交互相關(guān)的東西
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 鼠標(biāo)橫軸
event.y 鼠標(biāo)縱軸
event.keycode 鍵盤值
events.button==0 默認(rèn)。沒有按任何按鈕。
events.button==1 鼠標(biāo)左鍵
events.button==2 鼠標(biāo)右鍵
events.button==3 鼠標(biāo)左右鍵同時(shí)按下
events.button==4 鼠標(biāo)中鍵
events.button==5 鼠標(biāo)左鍵和中鍵同時(shí)按下
events.button==6 鼠標(biāo)右鍵和中鍵同時(shí)按下
events.button==7 所有三個(gè)鍵都按下

相關(guān)文章

最新評論