JedWatson / react-tappable

Tappable component for React
http://jedwatson.github.io/react-tappable/
MIT License
863 stars 90 forks source link

Accessibility: Add keydown/keyup support for toggling tappables #67

Closed wbinnssmith closed 8 years ago

wbinnssmith commented 8 years ago

Like mousedown/mouseup, this adds support to toggle tappables with the enter and space keys, similarly to how native buttons and links work with the keyboard.

Unlike touchstart and mousedown, the keypress event fires repeatedly (and triggers while held down, like its native counterparts), and I'm not sure whether or not this is a good thing. If held down long enough, the press callback gets called many times as well. Again, afaict this is how native buttons and links work.

All this means that <Tappable component="button"> behaves like it should :smile:

Thanks for the great library and all of your awesome components.

JedWatson commented 8 years ago

This looks great @wbinnssmith, thanks!

I was thinking, to preserve the "expected" behaviour for tappable, it would make sense to only fire the event tap "up" once per "down" event... afaik this is how a button behaves when the keyboard is used to fire an onClick handler?

I'll add a simple check in (and continue to allow the onKeyDown event through), let me know if you think it's not a good idea.

Thanks for the great library and all of your awesome components.

You're very welcome :grinning: