mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.13k stars 22.45k forks source link

preventDefault - table for default actions for each keyboard event on each element #30284

Closed raydleemsc closed 3 months ago

raydleemsc commented 10 months ago

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault

What specific section or headline is this issue about?

Missing - default actions

What information was incorrect, unhelpful, or incomplete?

What's missing is some kind of link to a table showing the default actions assigned to each key depending on the active element.

What did you expect to see?

Justification - This would be a useful reference when developing keyboard handling and when to prevent a default or not so it would be known what might be happening in specific circumstances by looking in one place instead of a different place for each key/element combination.

Do you have any supporting links, references, or citations?

Along the lines of Keyboard_event_key_values - but crossed against the base set of element types by tagname such as Web_HTML_Element

Do you have anything more you want to share?

No response

MDN metadata

Page report details * Folder: `en-us/web/api/event/preventdefault` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/event/preventdefault/index.md * Last commit: https://github.com/mdn/content/commit/32b07aa5b6ac4799a88e7b87a4d8333643ab6427 * Document last modified: 2023-07-20T02:15:46.000Z
dipikabh commented 9 months ago

Thanks for the suggestion, @raydleemsc.

Along the lines of Keyboard_event_key_values - but crossed against the base set of element types by tagname such as Web_HTML_Element

Could you explain a bit more about what you have in mind with this? Are you suggesting some sort of table that maps each key value to its default actions across different HTML elements?

I can imagine that there will be cross-browser variations, which might make it difficult to create such a reference, not to mention the overhead to keep such a reference up to date.

Josh-Cena commented 3 months ago

In general, we don't have these big compilation tables because they are extremely hard to maintain. There's also no normative standard for keyboard UX (although conventions like WAI-ARIA exist). Therefore I don't think this is tenable. As a webpage author, you are encouraged to only use preventDefault when you know for sure it would cause conflicting behavior otherwise (through testing).