Home > Web Front-end > JS Tutorial > js left and right mouse button keyboard value summary_javascript skills

js left and right mouse button keyboard value summary_javascript skills

WBOY
Release: 2016-05-16 18:25:13
Original
967 people have browsed it
Copy code The code is as follows:

function test()
{
alert(event. x " " event.y);
alert(event.button);
}
/*Right-click menu is not displayed*/
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);
}


event.x Mouse horizontal axis
event.y Mouse vertical axis
event.keycode Keyboard value
events.button= =0 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 simultaneously
events.button==4 Middle mouse button
events.button==5 The left and middle mouse buttons are pressed simultaneously
events.button==6 The right and middle mouse buttons are pressed simultaneously
events.button==7 All three keys are pressed Down
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template