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

@wordpress/keycodes

Package Overview
Dependencies
Maintainers
0
Versions
188
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.

4.27.0
latest
Source
npmnpm
Version published
Weekly downloads
218K
47.16%
Maintainers
0
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

wordpress

FAQs

Package last updated on 23 Jul 2025

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