Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpad keys not detected #89

Closed
ghost opened this issue Jun 3, 2019 · 12 comments · Fixed by #254
Closed

Numpad keys not detected #89

ghost opened this issue Jun 3, 2019 · 12 comments · Fixed by #254
Labels

Comments

@ghost
Copy link

ghost commented Jun 3, 2019

Numpad keys are not detected with normal handlers (they can be detected under the '*' handler, but not under a regular handler)

Demo:
https://jsfiddle.net/fk1o32a9/7/

Actual:
Using Digit1, event is detected for both events (both 1 and *)
Using Numpad1, event is detected only for "*" event

Expected:
Using Digit1, event is detected for both events (both 1 and *)
Using Numpad1, event is detected for both events (both 1 and *)

@jaywcjlove jaywcjlove added the bug label Jun 4, 2019
@jaywcjlove
Copy link
Owner

@swd120 I need to buy a keyboard.

@ghost
Copy link
Author

ghost commented Jun 4, 2019

Let me know if there's any additional info you might need.

@bichotll
Copy link

bichotll commented Jul 3, 2019

It works for me (mac).
@swd120 No offense - you sure that the keypad num is enabled?

@pablocar80
Copy link

@bichotll I was able to reproduce the issue with my keypad turned on and numlock off. It's like the library believes that the '1' from the keypad was a different key. The key does get captured under '*' but not under '1'.

@pascalrogalla
Copy link

pascalrogalla commented Oct 22, 2019

It seems to be a Windows issue.
Works fine on MAC.
Maybe because the KeyboardEvent.which is different between Mac and Windows.

That's my current Workaround:

hotkeys('*', ({key}) => {
   const keyValue = parseInt(key, 10)
   if(Number.isInteger(keyValue)){
      doSth(keyValue)
   }
})

@ishan576
Copy link

ishan576 commented Jun 12, 2020

I just added Numpad keys to _modifer variable and seems to work for me. The user will have to specify both the keys while initializing the hotkey

`

"num_0": 96,
"num_1": 97,
"num_2": 98,
"num_3": 99,
"num_4": 100,
"num_5": 101,
"num_6": 102,
"num_7": 103,
"num_8": 104,
"num_9": 105,
"num_multiply": 106,
"num_add": 107,
"num_enter": 108,
"num_subtract": 109,
"num_decimal": 110,
"num_divide": 111,`

Usage:
hotkeys('-,=,1,2,num_subtract,num_add,num_1,num_2', 'numpadScope');

@CourtHive
Copy link

I'm using react-hotkeys-hook ... @ishan576 are you suggesting that var.js needs to be modified and then build? I would then need to do a custom build of react-hotkeys-hook as well?

@jaywcjlove this looks pretty straightforward... any chance you could make the fix?

@ishan576
Copy link

I'm using react-hotkeys-hook ... @ishan576 are you suggesting that var.js needs to be modified and then build? I would then need to do a custom build of react-hotkeys-hook as well?

@jaywcjlove this looks pretty straightforward... any chance you could make the fix?

@CourtHive: My usage was in a pure js mode. But yes, I think you'll have to modify and re-build.

@CourtHive
Copy link

thanks @ishan576 appreciate the reply

@gimoteco
Copy link

gimoteco commented Aug 28, 2020

Same problem happening with me, trying to debug I noticed that it only happens on Firefox, on Chrome works fine. I'm using the react wrapper react-hotkeys-hook but the same problem happens in this lib's homepage.

@CourtHive
Copy link

@gimoteco are you saying that the numeric keys work for you on Chrome? We have tested in Chrome on Windows and it does not work. Based on @ishan576 comments above and looking at the code I don't think the key codes for numeric keypad are handled at all. I don't understand why this issue can't be addressed as the solution seems to be fairly straightforward...

@gimoteco
Copy link

gimoteco commented Sep 3, 2020

Yeah, testing in https://wangchujiang.com/hotkeys/ the numpad keys work on chrome and don't work on firefox (just the numpad digit keys).
I'm using MacOS 10.15.6, Firefox 80 and Chrome Version 85.0.4183.83 (Official Build) (64-bit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants