Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/talljack/vue3-hotkey
- Owner: Talljack
- License: mit
- Created: 2021-06-04T08:24:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-04T04:04:54.000Z (3 months ago)
- Last Synced: 2025-01-21T04:16:15.070Z (12 days ago)
- Topics: hooks, hotkeys, vue3
- Language: TypeScript
- Homepage: https://vue3-hot-key-demo.vercel.app/
- Size: 921 KB
- Stars: 26
- Watchers: 1
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# vue3-hotKey
Vue3 hooks of Keyboard input.## 📦 Install
```bash
pnpm i vue3-hotkeyor
yarn add vue3-hotkey
```## 🦄 Usage
```typescriptimport 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