react-hotkeys-hook icon indicating copy to clipboard operation
react-hotkeys-hook copied to clipboard

Feature: Add support for event capturing

Open ollieri3 opened this issue 1 year ago • 5 comments

This small change adds a new capture option to the useHotkeys hook. It determines whether key events will be triggered in the capturing or bubbling phase (default) during event propogation. More info here.

I've found this to be useful when setting up global hotkeys within an application where you may wish to override any child elements that stopPropagation().


I've added a test to verify this new behaviour along with documentation of the new option, please let me know If you'd like me to make any further changes.

Thanks for this awesome library.

ollieri3 avatar Oct 01 '24 10:10 ollieri3

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-hotkeys-hook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 10:04am

vercel[bot] avatar Oct 01 '24 10:10 vercel[bot]

@ollieri3 First of all sorry for the long wait! Second: Thank you so much for your contribution, it's an interesting new feature. Could you add info to the documentation pages as well? And I think you need to update your branch to reflect the latest changes on the main branch, then I'll merge it.

JohannesKlauss avatar Nov 02 '24 09:11 JohannesKlauss

I'm interested in this change as well for my use case, so thanks for putting up this PR. I noticed there hasn't been any activity in the past two months. @ollieri3 are you planning on adding the documentation here? I can try to help out with that (though not sure what the best way to do that would be).

sherwinyu avatar Jan 24 '25 05:01 sherwinyu

@ollieri3 This has to be updated to comply with version 5.

JohannesKlauss avatar Apr 10 '25 07:04 JohannesKlauss

Will this ever be merged? It's a very nice feature to have.

Aspecky avatar May 22 '25 14:05 Aspecky

@Aspecky You can use the eventListenerOptions options object and set capture: true

JohannesKlauss avatar Oct 13 '25 08:10 JohannesKlauss