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

hotkeys-js

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotkeys-js

A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

  • 3.13.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
449K
decreased by-0.83%
Maintainers
1
Weekly downloads
 
Created

What is hotkeys-js?

The hotkeys-js npm package is a simple library for handling keyboard shortcuts in web applications. It allows developers to define and manage keyboard shortcuts with ease, providing a straightforward API for binding and unbinding keys.

What are hotkeys-js's main functionalities?

Binding a single key

This feature allows you to bind a single key to a function. In this example, pressing the 'A' key will trigger a console log message.

hotkeys('a', function(event, handler) {
  console.log('You pressed A!');
});

Binding multiple keys

This feature allows you to bind multiple keys to a single function. In this example, pressing either 'Ctrl+A' or 'Ctrl+B' will trigger the same console log message.

hotkeys('ctrl+a, ctrl+b', function(event, handler) {
  console.log('You pressed either Ctrl+A or Ctrl+B!');
});

Binding key combinations

This feature allows you to bind key combinations to a function. In this example, pressing 'Ctrl+Shift+K' will trigger a console log message.

hotkeys('ctrl+shift+k', function(event, handler) {
  console.log('You pressed Ctrl+Shift+K!');
});

Unbinding keys

This feature allows you to unbind a previously bound key. In this example, the 'A' key will no longer trigger any function.

hotkeys.unbind('a');

Filtering key events

This feature allows you to filter which key events should be processed by hotkeys-js. In this example, all key events will be processed.

hotkeys.filter = function(event) {
  return true; // Process all key events
};

Other packages similar to hotkeys-js

Keywords

FAQs

Package last updated on 07 Feb 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