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?
7. What is currently clicked? Which element
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!