Create Custom Keyboard Shortcuts For Pages - key-binding.js

File Size: 5.33 KB
Views Total: 1546
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Create Custom Keyboard Shortcuts For Pages - key-binding.js

key-binding.js is a jQuery plugin to create custom keyboard shortcuts by binding specific keypress events to methods.

How to use it:

1. Load both jQuery JavaScript library and the JavaScript file key-binding.js in the document.

<script src="" 
<script src="jquery-key-binding.js"></script>

2. Create a field to accept the keyboard shortcut you prefer.

<div id="alertBinding"></div>

3. Initialize the plugin.

  name: 'openAlert', 
  key: 'a', 
  size: 100

4. Fire an event as you press the keyboard shortcut.

$(document).on('keyBinding', (event, binding) => {
  if ( === 'openAlert') alert('Hello World!')

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