jaywcjlove / hotkeys-js

➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
https://jaywcjlove.github.io/hotkeys-js
MIT License
6.61k stars 406 forks source link

Adding options / scope breaks callback in React #428

Open justin-betty opened 1 year ago

justin-betty commented 1 year ago

Hello,

When adding options the callback is not working any more in React 18.2.0

Adding it like this: hotkeys('esc', () => console.log('test')); works fine.

Adding it like this: hotkeys('esc', 'scope', () => console.log('test')); or hotkeys('esc', { scope: 'scope' }, () => console.log('test')); doesn't work.

Somehow the callback isn't triggered then

jaywcjlove commented 1 year ago

@justin-betty

hotkeys.setScope('scope');