Create Events Triggered By Keyboard Combinations – ShortcutsJS

Category: Javascript | January 29, 2018
Author:arjndr
Views Total:198 views
Official Page:Go to website
Last Update:January 29, 2018
License:MIT

Preview:

Create Events Triggered By Keyboard Combinations – ShortcutsJS

Description:

ShortcutsJS is a small JavaScript library that listens for keypress events and binds custom keypress events using the CustomEvent API.

How to use it:

Import the minified version of the ShortcutsJS library into the document.

<script src="shortcuts.js"></script>

Specify the element where you want to listen for the keypress events.

<input type="text" id="demo">
var inputShortcut = new Shortcuts(document.getElementById('inp'));

Bind a custom Keyboard Combination (shortcut) event to the input field when typed.

document.getElementById('inp').addEventListener('Ctrl+R', function(){
  alert('done');
});

You Might Be Interested In:


Leave a Reply