ayrton / react-key-handler

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

Firefox keypress == 0 - amend with which #145

Closed gforge closed 6 years ago

gforge commented 6 years ago

While keyCode together with keepress returns 0 in Firefox (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode). This can be mitigated to using a fallback thgrough the event.which argument:

if (!isNullOrUndefined(keyCode)) {
  // Firefox handles keyCode through which 
  const code = event.keyCode || event.which;
  return keyCode === code;
}

Although the change should probably be towards just `.code`: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
ayrton commented 6 years ago

Can you open a PR please

gforge commented 6 years ago

Already did https://github.com/ayrton/react-key-handler/pull/146

Not sure why it didn't link