Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

External keyboard numeric keypad does not substract resin on Firefox on macOS #55

Closed
Andrew67 opened this issue Mar 27, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@Andrew67
Copy link
Contributor

(I fully intend to submit a PR for this but as I'll explain below it's not currently possible)

This issue appears to be a perfect storm of:

  • Firefox on macOS
  • External keyboard that includes numeric keypad that I just started using
  • Using event.code or event.which instead of event.key for key handlers (which is what hotkeys JS does)

If you happen to have such a device on macOS you can test it out here: https://omatsuri.app/events-keycode

Basically, for e.g. 4, the top row key returns:
key: '4', code: 'Digit4', which: 52
but the numeric keypad returns (I think this matches NumLock off on Windows but macOS does not do NumLock):
key: '4', code: 'Numpad4', which: 100
Furthermore, Chrome seems to pave over this difference and returns the same as the top row key above, so it is left as a Firefox issue.

Solution:

  • Upgrade to a version of react-hotkeys-hook that uses hotkeys JS 3.8.3 (it's out, but the current 3.2.1 of the hook does not use it; it's in main branch so 3.2.2 probably)
  • Modify the Subtractor.tsx useHotkeys hook call to include the special key variant as defined in the library https://github.com/jaywcjlove/hotkeys/pull/254/files (4 becomes 4, num_4 for example)
@luaneko luaneko added the bug Something isn't working label Mar 27, 2021
@luaneko
Copy link
Member

luaneko commented Mar 27, 2021

Interesting. I can reproduce this on my mac with Firefox, although to be honest, it's not much of an inconvenience. The number of people who use Genshin Schedule on a macOS Firefox with numpad keys is probably very, very low.

But if you intend to fix this and submit a PR anyway, I will definitely have a look!

@Andrew67
Copy link
Contributor Author

Andrew67 commented Apr 3, 2021

Ready!
#56
Tested on Firefox/Edge on macOS

@luaneko luaneko closed this as completed in 438c3d3 Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants