Coder Social home page Coder Social logo

keyboard-key's Introduction

keyboard-key CircleCI Codecov David npm

A simple utility for determining the KeyboardEvent.key property from a keyboard event.

Install

yarn add keyboard-key

# or

npm install keyboard-key

Usage

getKey()

Get the key property value from an event.

document.addEventListener('keydown', event => {
  const key = keyboardKey.getKey(event)

  switch (key) {
    case 'Escape':
      // handle escape key
      break
    default:
      break
  }
})

See MDN or the source for a full list of key values.

getCode()

You can also get the normalized keyCode from an event. keyboard-key includes a hash of key names to keyCodes for easy comparisons:

document.addEventListener('keydown', event => {
  const code = keyboardKey.getCode(event)

  switch (code) {
    case keyboardKey.Escape: // 27
      // handle escape key
      break
    default:
      break
  }
})

Why?

Most previous key identifying KeyboardEvent properties have been pressed have been deprecated in favor of Keyboard.key.

๐Ÿ‘Ž KeyboardEvent.char
๐Ÿ‘Ž KeyboardEvent.charCode
๐Ÿ‘Ž KeyboardEvent.keyCode
๐Ÿ‘Ž KeyboardEvent.keyIdentifier
๐Ÿ‘Ž KeyboardEvent.keyLocation
๐Ÿ‘Ž KeyboardEvent.which

๐Ÿ‘ KeyboardEvent.key

Unfortunately, KeyboardEvent.key does not yet have full browser support. Leaving the browsers without a reliable property for identifying keyboard event keys.

Locale Caveat

This utility interprets use of the shift key when inferring event key values. Example, an event describing shift+/ would result in a key value of ?. 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 / is shift+7.

keyboard-key's People

Contributors

levithomason avatar greenkeeper[bot] avatar ecraig12345 avatar

Stargazers

muhammad ali avatar Nick Rawe avatar tyankatsu avatar Matt Huebert avatar Jason McWhorter avatar Marek Peล‚ka avatar Jose Albizures avatar ik5 avatar Elad Ossadon avatar Denis <ShiiRochi/> Bogdanenko  avatar Illia Kovalenko avatar Oleksandr Fediashov avatar Jakub T. Jankiewicz avatar Nathan Hutchision avatar David Zukowski avatar

Watchers

James Cloos avatar

keyboard-key's Issues

An in-range update of eslint-config-prettier is breaking the build ๐Ÿšจ

Version 2.10.0 of eslint-config-prettier was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint-config-prettier
Current Version 2.9.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci: Your tests failed on CircleCI (Details).

Commits

The new version differs by 4 commits.

  • 9f42779 eslint-config-prettier v2.10.0
  • 7a95862 Add more eslint-plugin-react rules
  • becbdf3 Add flowtype/boolean-style
  • 0f13166 Fix wording in readme

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

License

What license this package have? no info and no LICENSE file. you can add license directly from github using create file and naming it LICENSE after that you will be able to pick license.

Lot of JavaScript developers use MIT but LGPL will also be good.

An in-range update of prettier is breaking the build ๐Ÿšจ

โ˜๏ธ Greenkeeperโ€™s updated Terms of Service will come into effect on April 6th, 2018.

Version 1.11.0 of prettier was just published.

Branch Build failing ๐Ÿšจ
Dependency prettier
Current Version 1.10.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci Your tests failed on CircleCI Details

Release Notes Prettier 1.11: CSS fixes and new TypeScript feature support

๐Ÿ”— Release Notes

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of babel-eslint is breaking the build ๐Ÿšจ

Version 8.2.2 of babel-eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency babel-eslint
Current Version 8.2.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

babel-eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci Your tests failed on CircleCI Details

Commits

The new version differs by 6 commits.

  • 9a6d663 8.2.2
  • 51afa9e Allow newer versions of babel
  • 7928722 Update dependencies
  • f958995 chore(package): update lint-staged to version 6.1.1 (#592)
  • 29b12ab Bump deps (#591)
  • 236adb8 Fix: wrong token type of ! and ~ (fixes #576) (#577)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of greenkeeper-lockfile is breaking the build ๐Ÿšจ

Version 1.13.0 of greenkeeper-lockfile was just published.

Branch Build failing ๐Ÿšจ
Dependency greenkeeper-lockfile
Current Version 1.12.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

greenkeeper-lockfile is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci Your tests failed on CircleCI Details

Release Notes v1.13.0

1.13.0 (2018-01-19)

Features

  • add basic Codeship CI Integration (258e9c0)
Commits

The new version differs by 3 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Two keys pressed

Can this package solve the problem of pressing two keys at the same time, such as Ctrl + F

An in-range update of eslint-plugin-prettier is breaking the build ๐Ÿšจ

Version 2.6.0 of eslint-plugin-prettier was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint-plugin-prettier
Current Version 2.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci Your tests failed on CircleCI Details

Commits

The new version differs by 4 commits.

  • d772dfa Build: update package.json and changelog for v2.6.0
  • 9e0fb48 Update: Add option to skip loading prettierrc (#83)
  • e5b5fa7 Build: add Node 8 and 9 to Travis
  • 1ab43fd Chore: add test for vue parsing

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint-plugin-json is breaking the build ๐Ÿšจ

Version 1.2.1 of eslint-plugin-json was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint-plugin-json
Current Version 1.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-json is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci: Your tests failed on CircleCI (Details).

Commits

The new version differs by 8 commits.

  • 48145f6 Update jshint to 2.9.6
  • 1f6d1e8 Add .gitignore
  • 5498124 Update all third party dependencies to latest version
  • e42c8cc Update node.js version for CI
  • d2d48e3 Merge pull request #4 from bebraw/patch-1
  • 7d6f1dc Fix cli example
  • 113bf95 Merge pull request #3 from azeemba/unrecoverableSyntax
  • ff904eb Add tests for unrecoverable syntax error reported by JSHint

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint is breaking the build ๐Ÿšจ

Version 4.16.0 of eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint
Current Version 4.15.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ ci/circleci Your tests failed on CircleCI Details

Release Notes v4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796) (Michael Ficarra)
  • af043eb Update: Add NewExpression support to comma-style (#9591) (Frazer McLean)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813) (Matija Marohniฤ‡)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852) (Kevin Partington)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855) (PiIsFour)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847) (Kevin Partington)
  • 978574f Docs: Fix examples for no-useless-escape (#9853) (Toru Kobayashi)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815) (Kevin Partington)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816) (Kevin Partington)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831) (Teddy Katz)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820) (Teddy Katz)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819) (Teddy Katz)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818) (Teddy Katz)
  • 6a5cd32 Fix: prefer-destructuring error with computed properties (fixes #9784) (#9817) (Teddy Katz)
  • 601f851 Docs: Minor modification to code comments for clarity (#9821) (rgovind92)
  • b9da067 Docs: fix misleading info about RuleTester column numbers (#9830) (Teddy Katz)
  • 2cf4522 Update: Rename and deprecate object-property-newline option (#9570) (Jonathan Pool)
  • acde640 Docs: Add ES 2018 to Configuring ESLint (#9829) (Kai Cataldo)
  • ccfce15 Docs: Minor tweaks to working with rules page (#9824) (Kevin Partington)
  • 54b329a Docs: fix substitution of {{ name }} (#9822) (Andres Kalle)
Commits

The new version differs by 22 commits.

  • 33ca1ea 4.16.0
  • 1a9ddee Build: changelog update for 4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796)
  • af043eb Update: Add NewExpression support to comma-style (#9591)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847)
  • 978574f Docs: Fix examples for no-useless-escape (#9853)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818)

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.