About the use of js mouse button events and keyboard button events

不言
Release: 2018-06-30 11:26:22
Original
1517 people have browsed it

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

   

请单击你鼠标的左键或右键试试

Copy after login

2. What are the current mouse cursor coordinates

   

在此文档中按下你鼠标的左键看看!

Copy after login

3. What is the unicode code of the pressed key

   

在此文档中按下你键盘上的某个键看看

Copy after login

4. What is the coordinate of the current mouse cursor relative to the screen

   

点击你鼠标的左键

Copy after login

5. What are the current coordinates of the mouse cursor?

   

点击你鼠标的左键

Copy after login

6. Is the shift key pressed?

   

按下shit键,点击你鼠标的左键

Copy after login

7. What is currently clicked? Which element

   

在这里点击看看,这里是p

或者点击这里也可以呀,这里是h3

你想点我吗??

pic
Copy after login

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!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!