You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Maintainers
1
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