redux-shortcuts
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/redux-shortcuts package

0.0.3 • Public • Published

redux-shortcuts

Keyboard shortcuts in Redux.

Example

import {
  bindShortcuts,
  mousetrap,
  Mousetrap,
} from 'redux-shortcuts';
import {
  myActionCreator,
  myActionCreator2,
} from './actions';

bindShortcuts(
  [['command+a', 'ctrl+a'], myActionCreator],
  [['command+b', 'ctrl+b'], myActionCreator2],

  // Dispatch multiple actions
  [['command+c', 'ctrl+c'], [myActionCreator, myActionCreator2]],

  // Dispatch and prevent default behavior
  [['command+s', 'ctrl+s'], myActionCreator, true]
)(store.dispatch);

//
// This package exports an instance of Mousetrap.
// So the stopCallback of it can be overwritten.
//
mousetrap.stopCallback = (e, element, combo, sequence) => {
  // Do something.

  // And call the default implementation if you need.
  return Mousetrap.stopCallback(e, element, combo, sequence);
};

See also Mousetrap to define keyboard commands.

Readme

Keywords

Package Sidebar

Install

npm i redux-shortcuts

Weekly Downloads

124

Version

0.0.3

License

MIT

Last publish

Collaborators

  • nak2k