This article mainly introduces the usage of js mouse button events and keyboard button events. It summarizes and analyzes the common operation techniques of JavaScript for mouse and keyboard events in the form of examples. Friends in need can refer to the examples of this article.
Describes the usage of js mouse button events and keyboard button events. Share it with everyone for your reference, the details are as follows:
keydown, keyup, keypress: keyboard keys that belong to you
mousedown,mouseup: mouse keys that belong to you
When buttons When pressed, a keydown event occurs.
Keyup is triggered when the user lifts the key.
The complete key press process is divided into two parts: 1. Key press is pressed; 2. the button is released.
When the user presses the mouse button on this element, mousedown occurs
When the user releases the mouse button on this element, mouseup occurs
Example
1. Which mouse button was clicked
请单击你鼠标的左键或右键试试
2. What are the current mouse cursor coordinates
在此文档中按下你鼠标的左键看看!
3. What is the unicode code of the pressed key
在此文档中按下你键盘上的某个键看看
4. What is the coordinate of the current mouse cursor relative to the screen
点击你鼠标的左键
5. What are the current coordinates of the mouse cursor?
点击你鼠标的左键
6. Is the shift key pressed?
按下shit键,点击你鼠标的左键
7. What is currently clicked? Which element
在这里点击看看,这里是p
或者点击这里也可以呀,这里是h3
你想点我吗??
![]()
The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About the calculation method of JS function call stack stack size
Implementation of JavaScript image amplification technology
The above is the detailed content of About the use of js mouse button events and keyboard button events. For more information, please follow other related articles on the PHP Chinese website!