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

Secondary key symbols not firing event #164

Open
attenzione opened this issue Sep 29, 2020 · 1 comment
Open

Secondary key symbols not firing event #164

attenzione opened this issue Sep 29, 2020 · 1 comment
Assignees

Comments

@attenzione
Copy link

Describe the bug
Listening secondary key symbols (!@#$%^&*()_+?) not firing event.
However binding primary key together with secondary will work.

Example code

let keys = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '?'];
keyboardjs.on(keys, (event) => {
  console.log(event); // no output
});

keys = [...keys, '1', '/'];
// keys = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '?', '1', '/']
keyboardjs.on(keys, (event) => {
  console.log(event); // output from "!", "?", "/", "1"
});

Expected behavior
Expecting console.log output with event data when pressing Shift + Digit or other key, but nothing in console.

Enviroment (please include the following info):

  • OS: macOS
  • Browser Chrome
  • Version 2.6.4

Additional context
Maybe it's breaking change, but version 2.5.1 works this way.

@daniel-wer
Copy link
Contributor

I can confirm that this regression exists on the current master. A quick investigation shows that it was introduced in 9e4c40f#diff-d14f3cec4a52a2fa22986eaf22d8a236a14b5e16102741de6444b05a8eca7c29R366

The condition activeTargetKeys.some(k => keyCombo.keyNames.includes(k)) which needs to be fulfilled to trigger a bound handler is never true for shortcuts registered on secondary key symbols (or really any key name bound using the bindMacro function).

To illustrate with an example:

After registering keyboardJS.bind('!', console.log.bind(console, '!')); and pressing Shift + 1 to type the !, activeTargetKeys is ["1", "one"] but keyCombo.keyNames is ["!"].

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

No branches or pull requests

3 participants