JS gets the key value method for the left and right mouse keys

  • 2020-03-30 04:05:05
  • OfStack


function test() 
{ 
alert(event.x+" "+event.y); 
alert(event.button); 
} 
 
document.oncontextmenu=function() 
{ 
return false; 
} 
 
document.onkeydown=function() 
{ 
alert(event.keyCode); 
} 
</script>

Event.x mouse horizontal axis
Event.y on the vertical axis of the mouse
Event. Keycode keyboard value
Events. The button = = 0, the default. No buttons were pressed.
Events.button ==1 left mouse button
Events.button ==2 right mouse button
Events.button ==3 press the left and right mouse buttons at the same time
Events.button ==4 middle mouse button
Events.button ==5 press the left and middle mouse buttons at the same time
Events.button ==6 press the right and middle mouse buttons at the same time
Events.button ==7 press all three keys


Related articles: