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

@types/mousetrap

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/mousetrap

TypeScript definitions for mousetrap

  • 1.6.15
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
199K
decreased by-3.29%
Maintainers
1
Weekly downloads
 
Created

What is @types/mousetrap?

@types/mousetrap provides TypeScript definitions for the Mousetrap library, which is a simple library for handling keyboard shortcuts in web applications.

What are @types/mousetrap's main functionalities?

Binding a single key

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

Mousetrap.bind('a', function() { console.log('A key was pressed'); });

Binding multiple keys

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

Mousetrap.bind(['a', 'b'], function(e) { console.log('A or B key was pressed'); });

Binding key combinations

This feature allows you to bind key combinations to a callback function. In this example, pressing 'Ctrl+S' will prevent the default browser action and trigger a console log.

Mousetrap.bind('ctrl+s', function(e) { e.preventDefault(); console.log('Save command'); });

Unbinding keys

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

Mousetrap.unbind('a');

Triggering events programmatically

This feature allows you to trigger a key event programmatically. In this example, it will simulate the pressing of the 'A' key.

Mousetrap.trigger('a');

Other packages similar to @types/mousetrap

FAQs

Package last updated on 22 Nov 2023

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