hixie: Add examples for accessKeyLabel (whatwg r6773)

hixie: Add examples for accessKeyLabel (whatwg r6773)

http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.5421&r2=1.5422&f=h
http://html5.org/tools/web-apps-tracker?from=6772&to=6773

===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.5421
retrieving revision 1.5422
diff -u -d -r1.5421 -r1.5422
--- Overview.html 27 Oct 2011 20:06:18 -0000 1.5421
+++ Overview.html 27 Oct 2011 20:55:24 -0000 1.5422
@@ -53058,7 +53058,45 @@
   or digit.<p>User agents can provide users with a list of the keyboard
   shortcuts, but authors are encouraged to do so also. The <code title="dom-accessKeyLabel"><a href="#dom-accesskeylabel">accessKeyLabel</a></code> IDL attribute
   returns a string representing the actual key combination assigned by
-  the user agent.<h4 id="the-accesskey-attribute"><span class="secno">7.4.2 </span>The <dfn title="attr-accesskey"><code>accesskey</code></dfn> attribute</h4><p>All <a href="#html-elements">HTML elements</a> may have the <code title="attr-accesskey"><a href="#the-accesskey-attribute">accesskey</a></code> content attribute set. The
+  the user agent.<div class="example">
+
+   <p>In this example, an author has provided a button that can be
+   invoked using a shortcut key. To support full keyboards, the author
+   has provided "C" as a possible key. To support devices equipped
+   only with numeric keypads, the author has provided "1" as another
+   possibly key.</p>
+
+   <pre>&lt;input type=button value=Collect onclick="collect()"
+       <strong>accesskey="C 1"</strong> id=c&gt;</pre>
+
+  </div><div class="example">
+
+   <p>To tell the user what the shortcut key is, the author has 
+   this script here opted to explicitly add the key combination to the
+   button's label:</p>
+
+   <pre>function addShortcutKeyLabel(button) {
+<strong>  if (button.accessKeyLabel != '')
+    button.value += ' (' + button.accessKeyLabel + ')';</strong>
+}
+addShortcutKeyLabel(document.getElementById('c'));</pre>
+
+   <p>Browsers on different platforms will show different labels, even
+   for the same key combination, based on the convention prevalent on
+   that platform. For example, if the key combination is the Control
+   key, the Shift key, and the letter C, a Windows browser might
+   display "<samp>Ctrl+Shift+C</samp>", whereas a Mac browser might
+   display "<samp>^&#8679;C</samp>", while an Emacs browser might
+   just display "<samp>C-C</samp>". Similarly, if the key combination
+   is the Alt key and the Escape key, Windows might use
+   "<samp>Alt+Esc</samp>", Mac might use
+   "<samp>&#8997;&#9099;</samp>", and an Emacs browser might use
+   "<samp>M-ESC</samp>" or "<samp>ESC ESC</samp>".</p>
+
+   <p>In general, therefore, it is unwise to attempt to parse the
+   value returned from the <code title="dom-accessKeyLabel"><a href="#dom-accesskeylabel">accessKeyLabel</a></code> IDL attribute.</p>
+
+  </div><h4 id="the-accesskey-attribute"><span class="secno">7.4.2 </span>The <dfn title="attr-accesskey"><code>accesskey</code></dfn> attribute</h4><p>All <a href="#html-elements">HTML elements</a> may have the <code title="attr-accesskey"><a href="#the-accesskey-attribute">accesskey</a></code> content attribute set. The
   <code title="attr-accesskey"><a href="#the-accesskey-attribute">accesskey</a></code> attribute's value is
   used by the user agent as a guide for creating a keyboard shortcut
   that activates or focuses the element.<p>If specified, the value must be an <a href="#ordered-set-of-unique-space-separated-tokens">ordered set of unique

Received on Thursday, 27 October 2011 20:55:42 UTC