🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

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

Keyboard Shortcuts

Documentation

jquery-key-binding

A simple jQuery plugin that handles keyboard binding via named events

Installation

Include the script in your page after jQuery

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

Usage

// use the plugin on any empty div/span $('#emptyDiv').keyBinding({   name: 'openAlert', // the event's name   key: 'a' // default binding })  // when the key is pressed, the selected element emits a 'keyBinding' event // that bubbles up to the document $(document).on('keyBinding', (event, binding) => {   // the second argument contains the event's name   if (binding.name === 'openAlert') alert('Hello World!') })

Demo

https://jsfiddle.net/cpqsqk5u/5/


You May Also Like