jQuery Plugin For Handling Keyboard Shortcut Events

jQuery Plugin For Handling Keyboard Shortcut Events
File Size: 6.46 KB
Views Total: 1651
Last Update:
Publish Date:
Official Website: Go to website
License: MIT

keyboard-shortcuts.js is a super light jQuery plugin that allows the user to bind keyboard shortcut events to any element and when a key combination is pressed, an event is triggered following that keyboard shortcut. Supports modifier keys like shift, ctrl, alt, etc.

How to use it:

1. Include both jQuery library and the jQuery keyboard-shortcuts plugin's script on the webpage.

<script src="//code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="jquery.keyboard-shortcuts.js"></script>

2. Initialize the plugin and we're ready to go.


3. Binds custom keyboard shortcut events to the window element as follows:

.on('Shift+▲', function(){
  // do something
}).on('Shift+▼', function(){
  // do something

4. Enable the debug mode to output the log in the console.


This awesome jQuery plugin is developed by loganstellway. For more Advanced Usages, please check the demo page or visit the official website.