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

[HELP] How to ignore subsequent keys and use only single key? #290

Open
DudaGod opened this issue Sep 15, 2020 · 0 comments
Open

[HELP] How to ignore subsequent keys and use only single key? #290

DudaGod opened this issue Sep 15, 2020 · 0 comments

Comments

@DudaGod
Copy link

DudaGod commented Sep 15, 2020

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.

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

1 participant