A version of mousetrap-global-bind in an easy-to-use module
npm install bind-mousetrap-globalA mousetrap-global-bind module that doesn't assume the presence of a global object.
Perfect for use in a module environment like create-react-app as opposed to a tag approach.
``bash`
npm i bind-mousetrap-global
Setup
`js
import mousetrap from 'mousetrap'
import addGlobalBinds from 'bind-mousetrap-global'
addGlobalBinds(mousetrap)
`
Use
`js``
// This shortcut will fire even if the user has an input focused
mousetrap.bindGlobal('mod+s', saveDocument)
// This one won't
mousetrap.bind('n', newDocument)
This is a rewrite inspired by similar packages from ccampbell and Elvynia. It does not contain any of their code.