{"name":"keyboard-key","version":"1.1.0","description":"A simple utility for determining the KeyboardEvent.key property from a keyboard event.","main":"src/keyboardKey.js","typings":"index.d.ts","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":"9f856f11b2a0bda6ecb7d36bd255634b9a39fae6","homepage":"https://github.com/levithomason/keyboard-key#readme","_id":"keyboard-key@1.1.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-qkBzPTi3rlAKvX7k0/ub44sqOfXeLc/jcnGGmj5c7BJpU8eDrEVPyhCvNYAaoubbsLm9uGWwQJO1ytQK1a9/dQ==","shasum":"6f2e8e37fa11475bb1f1d65d5174f1b35653f5b7","tarball":"http://registry-npm.ywwl.com/keyboard-key/download/keyboard-key-1.1.0.tgz","fileCount":11,"unpackedSize":23092,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeH7qDCRA9TVsSAnZWagAAFu0P/RQrpN4ztqs1FKQVDI+T\nPZNW2/NngZOz7BAxy6m2nC0Rt1Xh2J5UmftNuzXKNAK8/FyBuRuhB3PJsJTH\nab5hebapO1DVwOWe9bLn7HfY93PkNB9HyfbAElr1kjZ5cxDcxNMLEtfLllkg\nUuCn7UasKQiStdmvW4BZEQjdPh5DFHSuHkt0GhAVyaKS3lLIbmnQjh0nBodX\nXLceawHTrRcLZxIRTCIDUtCAMaJ6f7N2D2IAnm25OrkUF0hnNAsFlBd9G+EP\nTena+IG1Y6k4L33ErBrKeasn2mJtZK6HPSgVMIUj8M40aM6JlbbNckgqkzPW\nN9B+yXrvQGs51CCWt4Vf02lDI5vuFfCrJxueblOojRpQ5sM6lz49ZQ7LZDt8\nhevwkHHcLI6XXf9djCLlBFv0Y+2dbtfElqfTYKGjSm11VUiK+Kggeb9Me89W\n/f/Vi3ikCdcHRs7nqXadA2N0kLCqoYw+4pkSDXb5/q8kMppH/35yZ4HuXrIp\nif/EibvvX+gUMbv4Q3U158W2VzJEJXnousJowVDz4PQkqVlwHt6htYgUi8GJ\natrhIRkSBqhA73JzWYXizBUee6POC2/NtrNZkpkUTB1su5beVXPWWwCE7GzO\nZuktl17bt2Bf02zBYYBJMecUJzxrt6M4bs+WiKlW7bA2qfal3RIAbuzLHWlf\ndNyU\r\n=IaPB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIESYHC/jZ3Ynu/cxiIqwWhIxadlFIQftxqfXN/c0K596AiEAqa9ZlRn5zLNG9ndzx9JydtvUE2xTZMEb6L4hr4zmpho="}],"size":7535,"noattachment":false,"key":"/keyboard-key/-/keyboard-key-1.1.0.tgz"},"maintainers":[{"name":"levithomason","email":"me@levithomason.com"}],"_npmUser":{"name":"levithomason","email":"me@levithomason.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/keyboard-key_1.1.0_1579137667157_0.7716042757670023"},"_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":1579137667365,"_cnpm_publish_time":1579137667365,"dist-tags":{"latest":"1.1.0"}}