Socket
Socket
Sign inDemoInstall

kee

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    kee

Turn keyboard events into legible key names.


Version published
Maintainers
1
Install size
8.50 kB
Created

Readme

Source

kee.js

Turn keyboard events into legible key names.

  • Home: https://github.com/twhb/kee.js
  • Demo: https://twhb.github.io/kee.js/demo.html
  • npm: kee

Introduction

This library exists because the same few bugs show up in most websites that implement keyboard shortcuts:

  • Poor cross-OS support
  • Poor cross-browser support
  • Modifiers are sometimes ignored
  • Key handling code is unreadable and difficult to maintain

Code using kee.js will neither have any of these issues, nor ever need to consider them.

API

kee(event)

Returns a string naming the key press than generated event.

event: A KeyboardEvent with type 'keyup' or 'keydown'.

Key press string format

Key press strings consist of all held modifiers, each followed by "+", follwed by the pressed key.

A key's name is its physical label, in lower case, with spaces removed. It is not always what the press would type - for example, "shift" types nothing, and "shift+4" types "$" (on a US keyboard).

Modifiers are "ctrl", "alt", "shift", and "windows", and always appear in that order. macOS's "Command" is given as "ctrl", and its Option as "alt".

If a key press can't be identified then the string 'unidentified' is returned. This shouldn't happen except on custom hardware.

FAQs

Last updated on 03 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc