ayrton / react-key-handler

React component to handle keyboard events :key:
http://ayrton.be/react-key-handler
387 stars 29 forks source link

Add W3C KeyboardEvent.key values support. #10

Closed leocavalcante closed 8 years ago

leocavalcante commented 8 years ago

As discussed at #7

KeyboardEvent.keyCode is deprecated, also MDN recommends to avoid it for new projects in favor of KeyboardEvent.key.

This PR is a result of following this recommendations without dropping the support for keyCode since not every browser has implemented the new standard yet.

The usage of keyValue instead of keyId as discussed at #7 is to match an ubiquitous terminology with current standards.

Now, despite letter case, the arrow keys values are the only difference I notice from keycodes naming to actual key values so keyNameVals might seams dummy, but it allows to map any another differences.

Hope it helps! Cheers

leocavalcante commented 8 years ago

Sorry about the flow mess. Just setup a Linux VM to properly test the project.

ayrton commented 8 years ago

Awesome work Leo, this is epic stuff 🙌

leocavalcante commented 8 years ago

@ayrton, thanks and I do agree with all of your appointments, so here are them. Glad to help! Learned a lot playing with this, I appreciate, loved this Flow thing, static analyses FTW!

ayrton commented 8 years ago

Glad you enjoyed it and you were able to learn something from this.

ayrton commented 8 years ago

Merged this in, will try to release a new version in the next couple days, thank you for your contribution!