react-hotkeys
react-hotkeys copied to clipboard
[HELP] How to ignore subsequent keys and use only single key?
Hello.
I don't understand how to configure HotKeys that it only call handler on one specified key press. Currently my handler calls even if I press subsequent keys.
Example:
import {GlobalHotKeys} from 'react-hotkeys';
const keyMap = {
PREV_SCREENSHOT: 'down'
};
const handlers = {
PREV_SCREENSHOT: () => console.log('called');
};
<GlobalHotKeys keyMap={keyMap} handlers={handlers} />
And the problem that if I press cmd+down (cmd pressed and don't released until down is not pressed too) then my handler is called. I try to use ignoreEventsCondition configure function and IgnoreKeys component but they do not help me to fix it.
So I had to explicitly set stub for cmd+down, like this:
const keyMap = {
PREV_SCREENSHOT: 'down',
IGNORE_CMD_DOWN: 'cmd+down'
};
const handlers = {
PREV_SCREENSHOT: () => console.log('called'),
IGNORE_CMD_DOWN: () => {}
};
Thank you.