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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kcuf/keymap

v0.1.3

Published

Yet another keystroke helper.

Downloads

13

Readme

@kcuf/keymap

基础比较

| Package | Version | Size | Download | Star | TS | Demo | Test | | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | | tinykeys | 3.0.0/2024 | 1.48kB | 41k/Week | 3.8k | ✅ | demo | - | | hotkeys-js | 3.13.7/2024 | 41.2kB | 363k/Week | 6.7k | ✍ | demo | Jest | | keymaster | 1.6.2/2014 | 8.58kB | 22k/Week | 6.5k | DT | | - | | mousetrap | 1.6.5/2019 | 33.9kB | 400k/Week | 11.7k | DT | | Mocha | | shortcutjs | 1.6.0/2017 | 12.9kB | 6/Week | 28 | ✅ | | Jest ★ | | hotkeys | 1.0.0/2014 | 15.1kB | 150/Week | 3 | JS | | |

其中 hotkeys OO 思想过重,用起来非常麻烦,后续不做计较。

功能比较

| - | tinykeys | hotkeys-js | keymaster | mousetrap | shortcutjs | | ---- | ---- | ---- | ---- | ---- | ---- | | 批量绑定 | ✅ 对象 | ✅ 逗号 | ✅ 逗号 | ✅ 数组 | ✅ 对象数组 | | 支持序列(Combo) | ✅ | ❌ | ❌ | ✅ | ❌ | | 安全解绑 | ✅ | ❌ | ❌ | ❌ | ❌ | | 暂停(pause/resume) | ❌ | ❌ | ❌ | ❌ | ✅ | | preventDefault | ❌ | return false | return false | return false | options | | stopPropagation | ❌ | return false | return false | return false | ❌ | | 触发条件 | ❌ | ❌ | ❌ | ❌ | ❌ | | 便捷绑定(? * 等) | ❌ | ❌ | ❌ | ✅ | ❌ | | 代码触发(trigger) | ❌ | ✅ | ❌ | ✅ | ❌ | | 符号 Modifiers(⇧⌥⌃⌘) | ❌ | ✅ | ✅ | ❌ | ❌ |

符号

| 符号 | key | code | ~~keyCode~~ | | --- | --- | --- | --- | | ⌃ | Control | ControlLeft / ControlRight | 17 | | ⌥ | Alt | AltLeft / AltRight | 18 | | ⇧ | Shift | ShiftLeft / ShiftRight | 16 | | ⌘ | Meta | MetaLeft / MetaRight | 224 | | ↑ | ArrowUp | ArrowUp | 38 | | ↓ | ArrowDown | ArrowDown | 40 | | ← | ArrowLeft | ArrowLeft | 37 | | → | ArrowRight | ArrowRight | 39 | | ⏎ / ↵ / ↩ | Enter | Enter | 13 | | ␣ | Space | Space | 32 | | ⎋ | Escape | Escape | 27 | | ⇥ | Tab | Tab | 9 | | ⇞ | PageUp | PageUp | ? | | ⇟ | PageDown | PageDown | ? | | ⌫ | Backspace | Backspace | 8 | | ⌦ | Delete | Delete | 46 |

FAQ

❓ 能否 stopPropagationpreventDefault

可以。由绑定方法的返回值决定:

  • 'stop'e.stopPropagation()
  • 'prevent'e.preventDefault()
  • falsee.stopPropagation() + e.preventDefault()
  • 其他 → 什么都不做

❓能否在回调中拿到事件对象?

不能,不需要,也不安全。

❓ Mac 下 F11 无响应?

系统快捷键权限更高,接管不了。

Ctrl++ 不行?

不行。换 Ctrl+=

❓ Combo 下使用 +

可以。比如设置 C + +,可以在按键序列 c⇧=⇧= 时触发。