THEMETRIAL

Tiny Key Binding JavaScript Library – Tinykeys.js

Author:jamiebuilds
Views Total:0 views
Official Page:Go to website
Last Update:July 31, 2020
License:MIT

Preview:

Tiny Key Binding JavaScript Library – Tinykeys.js

Description:

A super tiny (~0.4kb) JavaScript library for handling key bindings on the web app.

How to use it:

1. Install & download.

# NPM
$ npm i tinykeys --save

2. Import the Tinykeys.js.

# ES Module
import tinykeys from "tinykeys"

# Browser
<script src="https://cdn.jsdelivr.net/npm/tinykeys/dist/tinykeys.umd.js"></script>

3. Add keyboard shortcuts for actions in your web app.

tinykeys(window, {
  "Shift+D": () => {
    alert("The 'Shift' and 'd' keys were pressed at the same time")
  },
  "y e e t": () => {
    alert("The keys 'y', 'e', 'e', and 't' were pressed in order")
  },
  "$mod+KeyD": () => {
    alert("Either 'Control+d' or 'Meta+d' were pressed")
  },
})


Source link

Add comment

NOTE :

All visitors can share my site’s content on their blogs, sites, and social networks to enrich the content

Only share the source www.themetrial.com

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.