Create Events Triggered By Keyboard Combinations – ShortcutsJS

Category: Javascript | January 29, 2018
Authorarjndr
Last UpdateJanuary 29, 2018
LicenseMIT
Views205 views
Create Events Triggered By Keyboard Combinations – ShortcutsJS

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