angular/angular.js — pull request #10288 by marcysutton (2014-12-01 22:49:58+00:00)
Title: feat(ngAria): Bind keypress on ng-click w/ optional flag

This PR addresses a widespread accessibility issue: when `ng-click` is bound to non-interactive elements such as `

` or ``, keyboard events are not fired by default even though ngAria dynamically adds `tabindex="0"`. With this change, `keypress` events are dynamically bound alongside `ng-click` as long as ngAria's `bindKeypress` option is `true` and `ng-keypress` doesn't already exist.

This change overrides native DOM behavior in regards to `click` on custom controls like `

` (i.e. they don't fire). However, since ngAria adds `tabindex` by default it should further close the loop by eliminating the need to manually bind `ng-keypress`, since this is likely to be forgotten.

This is intended to be a starting point–there may be a better way to accomplish this. It should also be brought up that this implementation only interfaces with `ng-keypress`, not `ng-keyup` or `ng-keydown`.

Closes https://github.com/angular/angular.js/issues/9254