DEV Community

Discussion on: Adding keyboard shortcuts in React

Collapse
 
selbekk profile image
selbekk

Cool idea! Would love to use this with hooks too, like

function MyComponent(props) {
  const handleHotkey = React.useCallback(event => { ... }, []);
  useGlobalHotkey("ctrl+shift+p", handleHotkey);
  return (...);
}
Collapse
 
dmitryyudakov profile image
Dmitry Yudakov