Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/talljack/vue3-hotkey

vue3 hooks of keyboard input.
https://github.com/talljack/vue3-hotkey

hooks hotkeys vue3

Last synced: 2 days ago
JSON representation

vue3 hooks of keyboard input.

Awesome Lists containing this project

README

        

# vue3-hotKey




Vue3 hooks of Keyboard input.

## 📦 Install

```bash
pnpm i vue3-hotkey

or

yarn add vue3-hotkey
```

## 🦄 Usage
```typescript

import useHotkey, { HotKey, RemoveHandler } from 'vue3-hotkey'
import { ref } from 'vue'
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](https://github.com/XiNiHa/vue-use-hotkey)

## 📄 License

[MIT License](https://github.com/Talljack/vue3-hotKey/blob/main/LICENSE) © 2021-PRESENT [Talljack](https://github.com/Talljack)

## 🍺 Sponsor

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