jQuery Plugin For Adding Keyboard Shortcuts To Webpage - keyboardShortcut

jQuery Plugin For Adding Keyboard Shortcuts To Webpage - keyboardShortcut
File Size: 5.95 KB
Views Total: 1763
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

keyboardShortcut is a jQuery plugin used for creating custom keyboard shortcuts that give your users a quick way to control your web application without using a mouse.

How to use it:

1. Add the jQuery keyboardShortcut plugin after loading jQuery JavaScript library.

<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="keyboardShortcut.js"></script>

2. Add a keyboard shortcut that calls a specified function on your webpage. In this case, you will receive a JavaScript alert once you click on the 'a'.

$(document).ready(function(){
  $(document).keydown(function( e ){
   keyboardShortcut(
     {
       selector: e,
       key: 'a'
     },function() {
       alert('Alerta do atalho')
     }
   ) //close keyboardShortcut
  }) //close keydown
}) //close ready

3. Default plugin configurations.

// active the plugin
active: true,

// active debug
debug: true,

// default keyboard shortcuts
keys: {
  active:'f2',
  debug:'f4'
},

// enable shift / ctrl / alt combo keys
press: {
  shift: false,
  ctrl: false,
  alt: false
}

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