vue3-hotkey

Hotkey Hooks for Vue3
19,819 31
Install
npm install vue3-hotkey
Latest Version:1.0.6
Vue:3
License:MIT
Last Updated:Nov 4, 2024
Links: GitHub  ·  npm
Maintainer: caoyugang

vue3-hotKey

📦 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.

📄 License

MIT License © 2021-PRESENT Talljack

🍺 Sponsor

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

Related Packages

v-hotkey3

Vue 3.2.x directive for binding hotkeys to components.

95,647 4
@aplus-frontend/hooks

Vue hooks for Aplus frontend team.

11,237
@antd-vue/hooks

vue3 hooks library

1,122
@dfsj/hooks

通用的vue3 hooks函数

940
use-rx-vue

Description

353 0

Version History

Version Released License
1.0.6 MIT
1.0.5 MIT
1.0.4 MIT
1.0.3 MIT
1.0.2 MIT