简体   繁体   中英

Which event for any kind of button activation?

Which event should I use for any kind of button activation:

  • keyboard return
  • mouse click
  • finger touch

Do I need to define three event handlers or can I do this with just one?

The question aims plain JavaScript without any library use.

And what happens, when W3C invents a new event, which recognizes fart sounds to activate a button? Do I have to add a fourth event handler?

It depends on what action you want after the event is done.If you have a submit button then use mouse events like:

  1. onclick event - this activates whenever you click the left button on your mouse

  2. oncontextmenu - this is activated when the right button of the mouse is clicked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM