Secondary key symbols not firing event
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.
I can confirm that this regression exists on the current master. A quick investigation shows that it was introduced in https://github.com/RobertWHurst/KeyboardJS/commit/9e4c40f1c922dc3aebc3722c9b959f943a331ccd#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 ["!"].