JS mouse button event and keyboard key event Usage Example summary _javascript tips

Source: Internet
Author: User

This example describes the JS mouse button events and keyboard key event usage. Share to everyone for your reference, specific as follows:

Keydown,keyup,keypress: A keyboard key that belongs to you

Mousedown,mouseup: The mouse button that belongs to you

The KeyDown event occurs when the button is pressed.

The KeyUp is triggered when the user lifts the button.

The complete key press process is divided into two parts: 1. The key is pressed; 2. The key is loosened.

When the user presses the mouse button on this element, the MouseDown occurs

Occurs when the user releases the mouse button over this element MouseUp

Example

1. Which button of the mouse is clicked

 
 

2. What is the cursor coordinates of the current mouse?

 
 

3. What is the Unicode code that presses the key?

 
 

4. What are the coordinates of the current mouse cursor relative to the screen?

 
 

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

 
 

6. The SHIFT key is pressed

 
 

7. Which element is currently clicked

alert ("You clicked" + Tname + "element")
}
</script>
 
 

PS: Here again for you to provide a JS event on the online tool, summed up the JS commonly used event types and function functions:

JavaScript event and Feature description encyclopedia:

Http://tools.jb51.net/table/javascript_event

More readers interested in JavaScript-related content can view the site topics: "JavaScript window operations and tips summary", "javascript json operation tips Summary", "JavaScript switching effects and techniques summary", " JavaScript Search Algorithm Skills Summary, "JavaScript animation effects and techniques Summary", "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and skills summary" and The summary of JavaScript mathematical operational usage

I hope this article will help you with JavaScript programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.