npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

short-cutting

v1.10.0

Published

快捷键统一解决方案

Downloads

76

Readme

Short-cutting 快捷键事件统一解决方案

安装

yarn add short-cutting

or

npm i short-cutting

内置了 Typescript 支持

使用

ES6 项目中使用

  import { ShortCutting } from 'short-cutting/lib-esm'
  // 引入样式文件
  import 'short-cutting/index.css'

  // 最简使用
  const shortCutting = new ShortCutting()
  shortCutting.on({
    key: 'a',
  }, () => {
    console.log('a is clicked')
  })
  • 主键 支持 key 和 code 两种键声明方式
  shortCutting.on({
    key: 'a',
  }, () => {
    console.log('a is clicked')
  })

  shortCutting.on({
    code: 65
  }, () => {
    console.log('a is clicked')
  })
  • 支持 >=1 个辅助键,当前支持 ctrl, command/win, alt, shift
  shortCut.on({
    code: 65,
    content: '全选',
    ctrl: true,
    shift: true,
  }, () => {
    console.log('a')
  } )
  • 支持多种组合键,如果你想使用多套快捷键对应一种行为,比如 ctrl + c, command + c 都表示复制当前内容,那么可以使用 assistArray 数组来表示
  shortCut.on({
    content: '复制',
    assistArray: [{ctrl: true}, { meta: true}],
    showTip: true,
  }, () => {
    console.log('c')
  })

注意:assistArray 的优先级高于 key 和 code

  • 支持 keyUp 事件 第三个可选参数表示 keyUp 的回调函数

  • 支持多种闪烁时间选择

  const shortCut = new ShortCut({ duration: 'fast' }) // fast | medium | slow

CDN

js: `https://unpkg.com/short-cutting/_bundles/index.js`
css: `https://unpkg.com/short-cutting/_bundles/index.css`

调起快捷键一览,用于展示所有支持的快捷键

shortCutting.showInstruction()

当前支持的辅助键:

  • ctrl
  • meta (win | command)
  • shift
  • alt

@TODO 功能点:

  • [x] 1. 支持可选键,比如复制,可以使用 ctrl + c,也可以支持 command + c
  • [x] 2. 支持快捷键一览表,暴露方法调用
  • [ ] 3. 支持多种主题
  • [ ] 4. 支持八个方向的位置自定义(默认左下)
  • [x] 5. 支持 onbeforeunload 事件劫持
  • [x] 6. 支持三种闪烁间隔时间选择:fast | medium | slow
  • [ ] 7. 抽离单独的 type.d.ts 包
  • [x] 8. 支持 CDN 加载