/vue3-hotKey

vue3 hooks of keyboard events

Primary LanguageTypeScriptMIT LicenseMIT

vue3-hotKey

Vue3 hooks of Keyboard events

🦄 Usage

import useHotkey, { HotKey } 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 stop = useHotkey(hotkeys.value)
}

📦 Install

npm i vue3-hotkey

or

yarn add vue3-hotkey

🌸 Thanks

This project is heavily inspired by the following awesome projects.

📄 License

MIT License © 2021-PRESENT caoyugang_1