jQuery Plugin To Bind Custom Keyboard Combination Events - Mapkey

File Size: 3.77 KB
Views Total: 1390
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Bind Custom Keyboard Combination Events - Mapkey

Mapkey is a really small, easy-to-use jQuery plugin which enables you to bind specific keyboard shortcuts to methods supporting almost any keyboard combinations (ctrl, shift, alt, meta, etc).

How to use it:

1. Load jQuery library and the jquery.mapkey.js plugin right before the closing body tag.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.mapkey.js"></script>

2. The JavaScript to fire an event once you press on 'Ctrl+Shift+Alt+A'.

$(document).mapKey('Ctrl+Shift+Alt+A', function (e) {
  alert('Great!');
  return false;
});

3. Remove the keyboard binding manually.

var keyMap = $(document).mapKey('Ctrl+Shift+Alt+A', function (e) {
  alert('Great!');
  return false;
});

keyMap.remove();

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