Socket
Socket
Sign inDemoInstall

@hscmap/keybind

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @hscmap/keybind

This module provide a way for listening for key combination events with simple API.


Version published
Weekly downloads
504
increased by9.57%
Maintainers
1
Install size
6.50 kB
Created
Weekly downloads
 

Readme

Source

Keybind

This module provide a way for listening for key combination events with simple API.

Example (Source of the working demo)

  • Working DEMO
import * as keybind from "@hscmap/keybind"

window.addEventListener('load', () => {
    keybind.on('shift+x', () => alert('shift + X'))
    keybind.on('alt+x', () => alert('alt + X'))
    keybind.on('ctrl+x', () => alert('ctrl + X'))
    keybind.on('meta+x', () => alert('meta + X'))

    // can be triggered only once
    const off = keybind.on('shift+ctrl+x', () => {
        alert('shift + ctrl + X (triggered only once)')
        off()
    })

    const sources = ['shift+x', 'alt+x', 'ctrl+x', 'meta+x', 'shift+ctrl+x']
    for (const s of sources) {
        const html = keybind.html(s)
        const div = document.createElement('div')
        div.innerHTML = html
        document.body.appendChild(div)
    }
})

FAQs

Last updated on 01 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc