Socket
Socket
Sign inDemoInstall

@wordpress/keycodes

Package Overview
Dependencies
Maintainers
23
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/keycodes

Keycodes utilities for WordPress. Used to check for keyboard events across browsers/operating systems.


Version published
Weekly downloads
116K
increased by0.91%
Maintainers
23
Weekly downloads
 
Created

What is @wordpress/keycodes?

@wordpress/keycodes is a utility package that provides constants and helper functions for working with keyboard key codes. It is particularly useful for handling keyboard events in a consistent manner across different browsers and environments.

What are @wordpress/keycodes's main functionalities?

Keycode Constants

The package provides constants for common key codes, making it easier to reference and use them in your code without having to remember the numeric values.

const { ENTER, ESCAPE } = require('@wordpress/keycodes');
console.log(ENTER); // Outputs: 13
console.log(ESCAPE); // Outputs: 27

isKeyboardEvent

This helper function checks if a given keyboard event matches a specified key. It simplifies the process of handling specific key events.

const { isKeyboardEvent } = require('@wordpress/keycodes');
const event = new KeyboardEvent('keydown', { keyCode: 13 });
console.log(isKeyboardEvent(event, 'enter')); // Outputs: true

getKeycodeByKey

This function returns the keycode for a given key name, providing a convenient way to map key names to their corresponding key codes.

const { getKeycodeByKey } = require('@wordpress/keycodes');
console.log(getKeycodeByKey('Enter')); // Outputs: 13

Other packages similar to @wordpress/keycodes

Keywords

FAQs

Package last updated on 19 Sep 2024

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