Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

keyboard-key

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyboard-key

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

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
254K
increased by4.78%
Maintainers
1
Weekly downloads
 
Created

What is keyboard-key?

The keyboard-key npm package is a utility for working with keyboard events in JavaScript. It provides a simple way to get the key name from a keyboard event, which can be useful for handling keyboard shortcuts and other keyboard interactions in web applications.

What are keyboard-key's main functionalities?

Get Key Name from Event

This feature allows you to get the name of the key that was pressed during a keyboard event. The `getKey` function takes a keyboard event as an argument and returns the name of the key.

const key = require('keyboard-key');
document.addEventListener('keydown', (event) => {
  const keyName = key.getKey(event);
  console.log(`Key pressed: ${keyName}`);
});

Check if Key is a Modifier

This feature allows you to check if the key pressed is a modifier key (e.g., Shift, Control, Alt). The `isModifier` function takes a keyboard event as an argument and returns a boolean indicating whether the key is a modifier.

const key = require('keyboard-key');
document.addEventListener('keydown', (event) => {
  if (key.isModifier(event)) {
    console.log('Modifier key pressed');
  }
});

Other packages similar to keyboard-key

FAQs

Package last updated on 16 Jan 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc