Mousetrap is a standalone library with no external dependencies. It weighs in at around 2kb minified and gzipped and 4.5kb minified. Mousetrap has been tested and should work in Internet Explorer 6+, Safari, Firefox, and Chrome. The bind method is the main call you will be making. This will bind a specified keyboard command to a callback method. If you want to bind multiple key commands to the same callback you can pass in an array for the first argument. Mousetrap 1.4 introduced a generic mod helper which lets you set cross platform shortcuts. The sequence of keys feature was inspired by Gmail. Any keys separated by a space will be considered a sequence. If you type each key in order the final one in the sequence will trigger the callback. If you type a key not in the sequence or wait too long the sequence will reset. You can also make a sequence that includes key combinations within it.

Features

  • There are no external dependencies, no framework is required
  • It works with international keyboard layouts
  • You can bind Gmail like key sequences in addition to regular keys and key combinations
  • You can programatically trigger key events with the trigger() method
  • It works with the numeric keypad on your keyboard
  • The code is well documented/commented

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

Apache License V2.0

Follow Mousetrap

Mousetrap Web Site

You Might Also Like
Top-Rated Free CRM Software Icon
Top-Rated Free CRM Software

216,000+ customers in over 135 countries grow their businesses with HubSpot

HubSpot is an AI-powered customer platform with all the software, integrations, and resources you need to connect your marketing, sales, and customer service. HubSpot's connected platform enables you to grow your business faster by focusing on what matters most: your customers.
Get started free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Mousetrap!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript Libraries

Registered

2021-05-28