{"name":"keyboard-key","version":"1.0.2","description":"A simple utility for determining the KeyboardEvent.key property from a keyboard event.","main":"src/keyboardKey.js","author":{"name":"Levi Thomason"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/levithomason/keyboard-key.git"},"bugs":{"url":"https://github.com/levithomason/keyboard-key/issues"},"scripts":{"lint":"prettier --list-different \"**/*.js?(on|x)\" && eslint \"**/*.js?(on|x)\"","lint:fix":"prettier --write \"**/*.js?(on|x)\" && eslint --fix \"**/*.js?(on|x)\"","toc":"markdown-toc -i README.md","precommit":"yarn toc && lint-staged","prerelease":"yarn lint && yarn test","release:major":"yarn prerelease && ta-script npm/release major","release:minor":"yarn prerelease && ta-script npm/release minor","release:patch":"yarn prerelease && ta-script npm/release patch","test":"jest","test:watch":"yarn jest -- --watchAll"},"jest":{"collectCoverage":true,"collectCoverageFrom":["src/**/*.js","!**/node_modules/**","!**/test/**"],"coverageDirectory":"coverage","coverageThreshold":{"global":{"branches":50,"functions":50,"lines":50,"statements":50}},"roots":["./src","./test"],"testMatch":["**/*.spec.js"],"testEnvironment":"node"},"lint-staged":{"*.js?(on|x)":["prettier --write","eslint --fix","git add"]},"devDependencies":{"babel-eslint":"^8.0.0","eslint":"^4.4.1","eslint-config-prettier":"^2.3.0","eslint-plugin-json":"^1.2.0","eslint-plugin-prettier":"^2.2.0","greenkeeper-lockfile":"^1.8.1","husky":"^0.14.3","jest":"^22.1.3","lint-staged":"^6.0.1","markdown-toc":"^1.1.0","prettier":"^1.6.1","ta-scripts":"^2.5.2"},"gitHead":"bc36f34950e873c7045d2ab4dd2a80b64b38a774","homepage":"https://github.com/levithomason/keyboard-key#readme","_id":"keyboard-key@1.0.2","_npmVersion":"6.2.0","_nodeVersion":"8.11.1","_npmUser":{"name":"levithomason","email":"me@levithomason.com"},"dist":{"integrity":"sha512-05cjQmw4ss/YuY2utmVim0wywDyBZGUivo8siLPkWinwGWtKlO8/4RGbPUqNycwlD3u/3D15eNRjnNAyaTDs8g==","shasum":"212e14dde4c2059814336159bbc5acd0a348ca6b","tarball":"http://registry-npm.ywwl.com/keyboard-key/download/keyboard-key-1.0.2.tgz","fileCount":11,"unpackedSize":172520,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbZUDoCRA9TVsSAnZWagAAEUoP/1G+M3YAprs2K0JDWGUk\nwFKVlmjB1jDNpnlN3SXgH/zVeD1Y54ddOMxFlMypVhU774lBdLmXQP6F0uWf\nUX+FmruoI7/zs8iY/bhfq+b0pnEYqSkHTSgf0fuCNg64lEqGLnP9kbFPQ1HD\nA7YUIkG5+iW1dhTMJzlyYnUC8uwdVk92IiNUcQC86Q3PMga5Z3LRe1/KNfxH\niDdL4RvJXTIDfcJvR5Wu98RK9SwHdsCksbc2dKb0URHaDkjkSaOwaQq/cZSp\nwFWtqDBPOVJzRXVroZ+v+NekFUP1KGmYgDzzdlT5GuwwRjMtTzaFjpgOudUp\nLzikO7BKddMcB/qbGalGGOg4zGklVpkHlD3qpjnVQLQEECeA31KxM5hFIVBz\niIWt51DBiTNdP7cN3N8ssH2jIZw7DT+WridUXjcaCxYgPp9gVjNdLXftFsiv\nmClKWJJg9OoLWKUBfOkoucrSN502A7djVrB826jYnUNhh/hRnXtvU/6CKa4T\nNwh7c7/KttQrtmKCPJ/5sg1hUBR0LxZ7+wXbbFzsFy/xvo7upcj5/0telboO\n6XW+wFHMhPR2Vz+25xR/YdE8DobDQ8GasVuR7yoBrqM8ERSyVe4MItNRHrlw\ny/o/D1lkEHMngE4BWW1Uqu0hmaFLZO54F4tCy6KD8V2MoKvIrfq0hotwRGqx\nS2UM\r\n=0n01\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGly8oUV5uNKxgSsRD46K9DeS03PM3+Dd9Kz9bM/tRctAiEA54HFPtj0YG1jMWPeTU83Nk3vytpmScpeMsDRHLYrVmI="}],"size":49107,"noattachment":false,"key":"/keyboard-key/-/keyboard-key-1.0.2.tgz"},"maintainers":[{"name":"levithomason","email":"me@levithomason.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/keyboard-key_1.0.2_1533362407532_0.05846167416624737"},"_hasShrinkwrap":false,"readme":"keyboard-key\n[![CircleCI](https://img.shields.io/circleci/project/github/levithomason/keyboard-key/master.svg?style=flat-square)](https://circleci.com/gh/levithomason/keyboard-key/master)\n[![Codecov](https://img.shields.io/codecov/c/github/levithomason/keyboard-key/master.svg?style=flat-square)](https://codecov.io/gh/levithomason/keyboard-key)\n[![David](https://img.shields.io/david/levithomason/keyboard-key.svg?style=flat-square)](https://david-dm.org/levithomason/keyboard-key)\n[![npm](https://img.shields.io/npm/v/keyboard-key.svg?style=flat-square)](https://www.npmjs.com/package/keyboard-key)\n============\n\nA simple utility for determining the `KeyboardEvent.key` property from a keyboard event.\n\n<!-- toc -->\n\n- [Install](#install)\n- [Usage](#usage)\n  * [getKey()](#getkey)\n  * [getCode()](#getcode)\n- [Why?](#why)\n- [Locale Caveat](#locale-caveat)\n\n<!-- tocstop -->\n\n## Install\n\n```\nyarn add keyboard-key\n\n# or\n\nnpm install keyboard-key\n```\n\n## Usage\n\n### getKey()\n\nGet the `key` property value from an event.\n\n```js\ndocument.addEventListener('keydown', event => {\n  const key = keyboardKey.getKey(event)\n\n  switch (key) {\n    case 'Escape':\n      // handle escape key\n      break\n    default:\n      break\n  }\n})\n```\n\n>See [MDN][2] or the source for a full list of `key` values.\n\n### getCode()\n\nYou can also get the normalized `keyCode` from an event.  `keyboard-key` includes a hash of `key` names to `keyCode`s for easy comparisons:\n\n```js\ndocument.addEventListener('keydown', event => {\n  const code = keyboardKey.getCode(event)\n\n  switch (code) {\n    case keyboardKey.Escape: // 27\n      // handle escape key\n      break\n    default:\n      break\n  }\n})\n```\n\n## Why?\n\nMost previous key identifying KeyboardEvent properties have been pressed have been deprecated in favor of `Keyboard.key`.\n\n:-1: `KeyboardEvent.char`  \n:-1: `KeyboardEvent.charCode`  \n:-1: `KeyboardEvent.keyCode`  \n:-1: `KeyboardEvent.keyIdentifier`  \n:-1: `KeyboardEvent.keyLocation`  \n:-1: `KeyboardEvent.which`\n\n:+1: `KeyboardEvent.key`\n\nUnfortunately, `KeyboardEvent.key` does not yet have full [browser support][3].  Leaving the browsers without a reliable property for identifying keyboard event keys.\n\n## Locale Caveat\n\nThis utility interprets use of the shift key when inferring event `key` values.  Example, an event describing <kbd>shift</kbd>+<kbd>/</kbd> would result in a `key` value of <kbd>?</kbd>.  This logic assumes an `en-US` locale keyboard layout.  This will **not work** if you are using a different locale such as a German layout where <kbd>/</kbd> is <kbd>shift</kbd>+<kbd>7</kbd>. \n\n[1]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key\n[2]: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values\n[3]: http://caniuse.com/#feat=keyboardevent-key\n","publish_time":1533362407602,"_cnpm_publish_time":1533362407602,"dist-tags":{"latest":"1.1.0"}}