Reputation: 154
I am attempting to learn JavaScript and find this task to be a bit difficult in some respects. Currently I am looking into event support across the major browsers. As far as events go, there seems to be two general flavors: (1) the Microsoft way, and (2) the standardized way.
I am aware that IE 8 does not support DOM Level 2 Events, but that IE 9 is expected to support DOM Level 3 Events. On the Microsoft side there exists a distinct list of DHTML Events. A description of the event object is also available.
In the standardized way I am clumping together DOM Level 0 support which has no official specification, and DOM Level 2 Events that where written by the W3C. This standardized way is generally followed by all of the major browsers except MSIE, namely: Firefox, Chrome, Safari, and Opera. Each of the standardized browsers have a varying level of documentation around their support of events as indicated by the following links.
DOM Level 0 Events
Safari HTML Reference: Supported Attributes
HTML, XHTML, and WML in Opera Presto 2.8
No information for Chrome.
DOM Level 2 Events
Gecko DOM Events (appears to be incomplete)
WebKit Standards Support Targets (implicitly covering Chrome and Safari at a high level)
DOM 2 UI, Mouse & Mutation Events support in Opera Presto 2.8
Is it safe to say that the documentation across the standardized browsers is interoperable? I am aware of the Quirksmode Compatibility Tables in regards to this type of information. However, I hardly find that comforting when a problem is encountered and hope that there that are details I can count on instead. I'd also like to exclude libraries (such as Jquery and such) at this point.
Upvotes: 4
Views: 265
Reputation: 324687
No. There is much variation around key events within browsers, and the big libraries such as jQuery only normalize a bare minimum of it (correctly, in my view). The only way to deal with the inconsistencies is to learn from people who have learned the hard way. The best resource by miles that I've found is this page by Jan Wolter: http://unixpapa.com/js/key.html. Accurate and fairly comprehensive.
Upvotes: 2
Reputation: 35304
Most people use http://www.quirksmode.org/ as their main reference
Upvotes: 0
Reputation: 10059
Browsers have all sorts of quirks around things like detecting keypresses, etc. Not all of these bugs are obvious, or present in all versions of a browser. I doubt there's a single authoritative source that perfectly describes events even for any one browser, much less all of them. ppk is pretty incredibly comprehensive, but he's shifted his focus to mobile recently.
Anyway, you can probably write something that will mostly work, but these libraries have orders of magnitude more testing than you could possibly do by yourself. If your goal is to learn, then by all means explore and experiment. But don't reinvent the wheel. Whenever I want a standalone solution to a particular application of the DOM (e.g. what mouse button was pressed on a click event) I first look at documentation, and then I look at how the various libraries out there do it.
Upvotes: 1