{"_id":"@mapbox/react-keybinding","_rev":"275-e304d6b8a72e59171f5dcb8ffb5a66f1","name":"@mapbox/react-keybinding","description":"declarative, concise keybindings for react","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@mapbox/react-keybinding","version":"3.0.0","description":"declarative, concise keybindings for react","main":"index.js","scripts":{"test-ff":"node test.js && browserify test.js | tap-closer | smokestack -b firefox","test":"browserify test.js | tap-closer | smokestack"},"keywords":["keybinding","keybindings","react","react-component"],"author":{"name":"Tom MacWright"},"license":"BSD","devDependencies":{"browserify":"^9.0.3","happen":"^0.1.3","react":"^0.13.3","smokestack":"^3.2.0","tap-closer":"^1.0.0","tape":"^3.5.0"},"peerDependencies":{"react":">=0.13.0 <16.0.0"},"repository":{"type":"git","url":"git+ssh://git@github.com/mapbox/react-keybinding.git"},"gitHead":"bdcbb9394522e839a02b9f5c17d3e3ac809b8ec7","bugs":{"url":"https://github.com/mapbox/react-keybinding/issues"},"homepage":"https://github.com/mapbox/react-keybinding#readme","_id":"@mapbox/react-keybinding@3.0.0","_shasum":"b8e4029e46916089cc4c54d224f7617fec602f75","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.2.1","_npmUser":{"name":"mapbox-admin","email":"accounts@mapbox.com"},"dist":{"shasum":"b8e4029e46916089cc4c54d224f7617fec602f75","tarball":"https://registry.npmjs.org/@mapbox/react-keybinding/-/react-keybinding-3.0.0.tgz","integrity":"sha512-7WeFyyvhkVRhlfEMRAzaJtGfXbgFWxi3R9VW5X8xSmCLWbhDLYePqAQM3zOiLlXZBT0dgleEnRVRs0bcbQvgPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD+6DtumSboa5NPYMgNs+Pny7XQEemExMIeP6dVIIvmJwIhAPJbxS/n0KFGt8ZTsuOpXu5ytD6aO5xzBAdXlBbwKZeL"}]},"maintainers":[{"name":"mapbox-admin","email":"accounts@mapbox.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/react-keybinding-3.0.0.tgz_1482369616202_0.5242690292652696"},"directories":{}}},"readme":"# react-keybinding\n\n[![build status](https://secure.travis-ci.org/mapbox/react-keybinding.png)](http://travis-ci.org/mapbox/react-keybinding)\n\nDeclarative, lightweight, and robust keybindings mixin for React.\n\n* Straightforward `'⌘S'` string syntax for declaring bindings\n* Automatically binds & unbinds keybindings when components mount and unmount\n* Allows listing of all currently-active keybindings\n* Run a function when a keybinding is hit or pass an action\n  to the `keybinding` method of that component\n* Doesn't fire keybindings accidentally triggered in inputs,\n  select boxes, or textareas.\n* Optionally coerce platform specific keybindings (i.e. `'⌘S'` on Mac to `'^S'` on Windows)\n\n## Installation\n\nInstall with [npm](https://www.npmjs.com/) and use in your React\nprojects with either [browserify](http://browserify.org/) or\n[webpack](http://webpack.github.io/).\n\n```sh\n$ npm install react-keybinding\n```\n\n## Example\n\n```js\nvar React = require('react'),\n    Keybinding = require('../');\nvar HelloMessage = React.createClass({\n  mixins: [Keybinding],\n  keybindingsPlatformAgnostic: true,\n  keybindings: {\n    '⌘S': function(e) {\n      console.log('save!');\n      e.preventDefault();\n    },\n    '⌘C': 'COPY'\n  },\n  keybinding: function(event, action) {\n    // event is the browser event, action is 'COPY'\n    console.log(arguments);\n  },\n  render: function() {\n    return React.createElement(\"div\", null, \"Hello\");\n  }\n});\nReact.render(React.createElement(HelloMessage, {name: \"John\"}), document.body);\n```\n\nThere's a runnable example in the `./examples` directory: to run it,\n\n```sh\n$ npm install\n$ cd example\n$ npm install\n$ npm start\n```\n\nSee [tmcw/ditty](https://github.com/tmcw/ditty) for an example of\nreact-keybinding in an application.\n\n### API\n\nThis module exposes a single mixin called `Keybinding`.\n\nWhere you use this mixin on Components, it expects a property called\n`keybindings` of the format:\n\n```js\nkeybindings: {\n  // keys are strings: they can contain meta and shift symbols,\n  // numbers, strings, etc\n  '⌘S': function(e) {\n    // bindings can map to functions that they call directly\n  },\n  // or to constants that are passed to the component's\n  // 'keybinding' method.\n  '⌘C': 'COPY'\n}\n```\n\nPlatform agnostic keybindings will automatically listen for the `'Ctrl'`\nequivalent of `'Cmd'` keybindings, and vice-versa. To automatically coerce\nplatform specific keybindings, provide a property called\n`keybindingsPlatformAgnostic` of the format:\n\n```js\nkeybindingsPlatformAgnostic: true,\nkeybindings: { ... }\n```\n\nThe mixin provides a method for components called `.getAllKeybindings()`:\nthis yields an array of all `keybindings` properties on all active components.\n\n## [Syntax](SYNTAX.md)\n\nThe full [range of codes and modifiers supported is listed in SYNTAX.md](SYNTAX.md).\n\n## Tests\n\n```sh\n$ npm test\n```\n","maintainers":[{"email":"yannick.meeus+npm+production+ci@mapbox.com","name":"mbx-npm-ci-production"},{"email":"yannick.meeus+npm+staging+ci@mapbox.com","name":"mbx-npm-ci-staging"},{"email":"yannick.meeus+npm+prod+advanced+actions@mapbox.com","name":"mbx-npm-advanced-actions-production"},{"email":"yannick.meeus+npm+staging+advanced+actions@mapbox.com","name":"mbx-npm-advanced-actions-staging"},{"email":"yannick.meeus+npm+prod+09@mapbox.com","name":"mbx-npm-09-production"},{"email":"yannick.meeus+npm+prod+08@mapbox.com","name":"mbx-npm-08-production"},{"email":"yannick.meeus+npm+prod+07@mapbox.com","name":"mbx-npm-07-production"},{"email":"yannick.meeus+npm+prod+06@mapbox.com","name":"mbx-npm-06-production"},{"email":"yannick.meeus+npm+prod+05@mapbox.com","name":"mbx-npm-05-production"},{"email":"yannick.meeus+npm+prod+04@mapbox.com","name":"mbx-npm-04-production"},{"email":"yannick.meeus+npm+prod+03@mapbox.com","name":"mbx-npm-03-production"},{"email":"yannick.meeus+npm+prod+02@mapbox.com","name":"mbx-npm-02-production"},{"email":"yannick.meeus+npm+prod+01@mapbox.com","name":"mbx-npm-01-production"},{"email":"yannick.meeus@mapbox.com","name":"mbx-npm-02-staging"},{"email":"accounts+npmjs-01@mapbox.com","name":"mapbox-npm-01"},{"email":"accounts+npmjs-02@mapbox.com","name":"mapbox-npm-02"},{"email":"accounts+npmjs-07@mapbox.com","name":"mapbox-npm-07"},{"email":"accounts+npmjs-03@mapbox.com","name":"mapbox-npm-03"},{"email":"accounts+npmjs-04@mapbox.com","name":"mapbox-npm-04"},{"email":"accounts+npmjs-09@mapbox.com","name":"mapbox-npm-09"},{"email":"accounts+npmjs-05@mapbox.com","name":"mapbox-npm-05"},{"email":"accounts+npmjs-06@mapbox.com","name":"mapbox-npm-06"},{"email":"accounts+npmjs-08@mapbox.com","name":"mapbox-npm-08"},{"email":"accounts+npmjs-advanced-actions@mapbox.com","name":"mapbox-npm-advanced-actions"},{"email":"accounts+npmjs-npm-ci@mapbox.com","name":"mapbox-npm-ci"},{"email":"accounts+npmjs@mapbox.com","name":"mapbox-npm"},{"email":"accounts@mapbox.com","name":"mapbox-admin"},{"email":"accounts+npm-mapbox-machine-user@mapbox.com","name":"mapbox-machine-user"}],"time":{"modified":"2023-01-12T12:45:01.003Z","created":"2016-12-22T01:20:18.105Z","3.0.0":"2016-12-22T01:20:18.105Z"},"homepage":"https://github.com/mapbox/react-keybinding#readme","keywords":["keybinding","keybindings","react","react-component"],"repository":{"type":"git","url":"git+ssh://git@github.com/mapbox/react-keybinding.git"},"author":{"name":"Tom MacWright"},"bugs":{"url":"https://github.com/mapbox/react-keybinding/issues"},"license":"BSD","readmeFilename":"README.md"}