hotkeys-js
hotkeys-js copied to clipboard
Can't detect shift alone
Shift by itself doesn't work.
hotkeys('shift', function() {
console.log('Shift pressed')
})
Here's a working example: CodeSandbox
@ashconnell Modifier keys cannot be set.
hotkeys("*", function(event, handler) {
console.log("event", event);
console.log("handler", handler);
if (hotkeys.shift) {
console.log("shift is pressed!");
}
if (hotkeys.ctrl) {
console.log("ctrl is pressed!");
}
if (hotkeys.alt) {
console.log("alt is pressed!");
}
if (hotkeys.option) {
console.log("option is pressed!");
}
if (hotkeys.control) {
console.log("control is pressed!");
}
if (hotkeys.cmd) {
console.log("cmd is pressed!");
}
if (hotkeys.command) {
console.log("command is pressed!");
}
});
@jaywcjlove how would I differentiate between shift
and shift+command+z
then? I don't want the shift behaviour to happen when they actually pressed other keys with it
@ashconnell Could you find anything?
@m98 I wrote my own key state machine where if "shift + command + z" is down then it "cancels" the "shift" binding
@ashconnell You mean by using this library? or just writing it by your own code?
@jaywcjlove how would I differentiate between
shift
andshift+command+z
then? I don't want the shift behaviour to happen when they actually pressed other keys with it
I guess if we make two binding, when we want them to trigger independently, or does binding z
does not trigger if we bind shift+command+z
?