Socket
Socket
Sign inDemoInstall

vue3-hotkey

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-hotkey

Hotkey Hooks for Vue3


Version published
Weekly downloads
3.2K
increased by21.91%
Maintainers
1
Weekly downloads
 
Created
Source

vue3-hotKey

Vue3 hooks of Keyboard input.

📦 Install

pnpm i vue3-hotkey

or

yarn add vue3-hotkey

🦄 Usage

import useHotkey, { HotKey, RemoveHandler } from 'vue3-hotkey'
import { ref } from 'vue'
setup() {
  const hotkeys = ref<HotKey[]>([
    {
      keys: ['space'],
      preventDefault: true,
      handler(keys) {
        countRef.value += 5
      }
    },
    {
      keys: ['shift', 'space'],
      preventDefault: true,
      handler(keys) {
        countRef.value -= 100
      }
    }
  ])
  const stopArr = useHotkey(hotkeys.value)

  // 取消监听快捷键
  const removeHotKeys = (hk: HotKey) => {
    stopArr.foreach((item: RemoveHandler) => item())
  }
}

🌸 Thanks

This project is heavily inspired by the following awesome projects.

  • vue-use-hotkey

📄 License

MIT License © 2021-PRESENT Talljack

🍺 Sponsor

如果大家喜欢我的项目的话,可以请我喝杯咖啡哦,谢谢!

Keywords

FAQs

Package last updated on 11 Mar 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc