react-shortcuts
react-shortcuts copied to clipboard
ShortCuts preventing other key handling event to call
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 ??
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.