2.0.0 • Published 8 years ago

get-key v2.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

get-key-js

Key identifier

API

getKey(e)

Returns a string identifying the key pressed to generate keydown or keyup event e, including modifiers.

Results look like "ctrl+shift+f". Formally, they consist of all held modifiers in the order "ctrl", "alt", "shift", then "windows", each followed by "+", followed by the label on the key, all in lowercase with spaces removed.

Mac-specific modifiers are given as their standard (near-)equivalents: Option is "alt" and Command is "ctrl". Unrecognized keys are given as "unrecognized"; only custom hardware should return "unrecognized", if it happens otherwise then please open an issue.

Please note well that get-key-js works with keys, not characters. For example, pressing "shift+4" yields "shift+4" (what was pressed), not "$" (what was typed, maybe, depending on the layout and system settings).

Setup

Install: npm install get-key

Import: const getKey = require('get-key');