Key identifier

Usage no npm install needed!

<script type="module">
  import getKey from '';



Key identifier



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 "quot; (what was typed, maybe, depending on the layout and system settings).


Install: npm install get-key

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