1.0.6 • Published 1 year ago

vue3-hotkey v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

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

1.0.6

1 year ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago