react-hotkeys icon indicating copy to clipboard operation
react-hotkeys copied to clipboard

[BUG] letter combination doesn't work in Windows

Open Ray-Hong opened this issue 6 years ago โ€ข 2 comments

Describe the bug A clear and concise description of what the bug is. if I define the key map as this:

const keyMap = {
      openDialog: 'a+b',
};

It doesn't work in Chrome/IE11/Edge on Windows environment. On Mac Chrome Version 77.0.3865.90, 'a+b' and 'b+a' will both trigger the same event in handler.

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc) I'm using HotKeys

Expected behavior A clear and concise description of what you expected to happen.

'a+b' should trigger the event on Windows and Mac correctly.

Platform (please complete the following information):

  • Version of react-hotkeys 2.0.0
  • Browser [e.g. chrome, safari] IE 11, chrome on Mac and Windows
  • OS: [e.g. iOS] Mac OS

Are you willing and able to create a PR request to fix this issue?

APPLICABLE TO v2.0.0-pre1 AND ABOVE: ======================

Include the smallest log that includes your issue:

In windows. After click 'a' the log says it looks for map action and no match. Then log shows a 'a' keyup event without I releasing the key. Then it looks for the 'b' keydown match. So it never finds the combination.

Paste logs in Windows Chrome when I do 'a+b':

HotKeys (F2๐Ÿ“˜-E9๐Ÿ’›-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'a' keydown event.
AbstractKeyEventStrategy.js?b56c:429 HotKeys (F2๐Ÿ“˜-E9๐Ÿ’›-C0๐Ÿ”บ-P0๐Ÿ”บ:) No matching actions found for 'a' keydown.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F2๐Ÿ“˜-E10๐Ÿ’œ-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'a' keypress event.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F2๐Ÿ“˜-E11๐Ÿงก-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'a' keyup event.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F2๐Ÿ“˜-E12โค๏ธ-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'b' keydown event.
AbstractKeyEventStrategy.js?b56c:429 HotKeys (F2๐Ÿ“˜-E12โค๏ธ-C0๐Ÿ”บ-P0๐Ÿ”บ:) No matching actions found for 'b' keydown.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F2๐Ÿ“˜-E13๐Ÿ’š-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'b' keypress event.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F2๐Ÿ“˜-E14๐Ÿ’™-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'b' keyup event.

In Chrome Mac. The key press array is correct. But the order doesn't work properly.

'a+b' log:

New 'a' keydown event.
AbstractKeyEventStrategy.js?b56c:429 HotKeys (F1๐Ÿ“—-E1๐Ÿ’š-C0๐Ÿ”บ-P0๐Ÿ”บ:) No matching actions found for 'a' keydown.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F1๐Ÿ“—-E2๐Ÿ’™-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'a' keypress event.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F1๐Ÿ“—-E3๐Ÿ’›-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'b' keydown event.
AbstractKeyEventStrategy.js?b56c:418 HotKeys (F1๐Ÿ“—-E3๐Ÿ’›-C0๐Ÿ”บ-P0๐Ÿ”บ:) Found action that matches 'a+b': openDialog. Calling handler . . .

'b+a' log:

New 'b' keydown event.
AbstractKeyEventStrategy.js?b56c:429 HotKeys (F5๐Ÿ“—-E6โค๏ธ-C0๐Ÿ”บ-P0๐Ÿ”บ:) No matching actions found for 'b' keydown.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F5๐Ÿ“—-E7๐Ÿ’š-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'b' keypress event.
FocusOnlyKeyEventStrategy.js?98f4:298 HotKeys (F5๐Ÿ“—-E8๐Ÿ’™-C0๐Ÿ”บ-P0๐Ÿ”บ:) New 'a' keydown event.
AbstractKeyEventStrategy.js?b56c:418 HotKeys (F5๐Ÿ“—-E8๐Ÿ’™-C0๐Ÿ”บ-P0๐Ÿ”บ:) Found action that matches 'a+b': openDialog. Calling handler . . .'

Set logging to verbose (you'll need the development build if its possible):

import { configure } from 'react-hotkeys';

configure({
  logLevel: 'verbose'
})

What Configuration options are you using?

All default configs.

configure({
  //options
})

Ray-Hong avatar Oct 04 '19 23:10 Ray-Hong

Hi @Ray-Hong,

Thank you for taking the time to fill out the bug reporting template correctly. That is really helpful.

I can see for the logs that on Windows Chrome, react-hotkeys seems to think you are releasing the a key before you press the b key.

I'll need to investigate this further and find out why on the Windows version of Chrome the keyup native event is being emitted despite you not releasing the key. I am not sure if this something in React or Chrome.

Would you mind telling me what version of React you are using?

greena13 avatar Oct 20 '19 13:10 greena13

Hey @greena13 ,

Thank you for replying. I'm using React 16.8.5. Please let me know if you have any questions.

Ray-Hong avatar Oct 22 '19 17:10 Ray-Hong