This is a proposal to extend HTML with an accessKeyLabel DOM attribute. In contrast to the HTML5 version, this proposal includes a microsyntax based on DOM UI Events that ensures the value returned is parseable

This is an unofficial draft. There is one implementation of accessKeyLabel, in Firefox, which followed HTML5 in allowing different syntax for different platforms. It was therefore removed from HTML 5.1. This proposal is open for discussion in the Web Platform Incubator, or issue, comments and pull requests are welcome in this draft's github repository.

Why accessKeyLabel?

User Agents actually assign accesskeys and other shortcuts - or block them. So user agents should inform the user of assigned activation triggers or focusing shortcuts. However, they generally do this badly, and authors are used to doing so - in part because successive specifications for accesskey have asked them to do so in an apparently thoughtless violation of the "priority of constituencies" design principle.

The accessKeyLabel DOM attribute's advantage is that it allows authors to do so in ways that are natural to the flow of their application.

This script explicitly adds the activation shortcut to a button's label:

function addShortcutKeyLabel(button) {
  if (button.accessKeyLabel != '')
    button.value += ' (' + button.accessKeyLabel + ')';
}
 
addShortcutKeyLabel(document.getElementById('c'));

Implementation

@@specify the microsyntax… [note that aria-kbdshortcuts has an attempt at this. These need to be aligned]

@@insert the assignment in the HTML accesskey processing algorithm.

@@add the attribute to HTMLElement.

The accessKeyLabel IDL attribute must return a string that represents the element's assigned access key, if any. If the element does not have one, then the IDL attribute must return the empty string.

Security and Privacy considerations

@@Needs review

accessKeyLabel can be used as information for fingerprinting a user, in particular if the user sets up their browser to specify shortcut activations that are adapted to their personal needs or preferences.

Acknowledgements

Many thanks to Robin Berjon for making our lives so much easier with his cool tool, The HTML Working Group behind HTML 4, Simon Pieters and later James Craig for realising that accesskey is a useful feature for many people, Ian Hickson for showing that implementation is critically important, Mozilla for doing an implementation of the HTML5 version of accessKeyLabel,  many people for contributing to the discussion on how discoverability is critical.