react-shortcuts icon indicating copy to clipboard operation
react-shortcuts copied to clipboard

ShortCuts preventing other key handling event to call

Open singhalsurbhi07 opened this issue 8 years ago • 1 comments

I have a component on which I have Shortcuts implemented for arrow keys. Then I have another component parallel to that which uses onKeyPress event. The issue is the keyPress event works fine till the component with ShortCut is not loaded. Once the component with Shortcut is loaded my keyPress event doesnot work. Any idea why ??

singhalsurbhi07 avatar Jun 07 '17 23:06 singhalsurbhi07

Hey singhalsurbhi07,

I believe this is an issue with react-shortcuts: it prevents onKeyPress events from firing.

You can get around this by switching to onKeyDown or onKeyUp and using the isolate prop in you <Shortcuts> component:

<Shortcuts name='TODO_ITEM' isolate handler={ myHandler }>
    // ...
</Shortcuts>

<YourComponent onKeyDown={ this.handler } />

I have created a pull request for what I think are some improvements to the documentation that explains this further. You can read more about this issue here.

greena13 avatar Oct 15 '17 12:10 greena13