Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daybrush/keycon
Keyboard Controller
https://github.com/daybrush/keycon
Last synced: about 10 hours ago
JSON representation
Keyboard Controller
- Host: GitHub
- URL: https://github.com/daybrush/keycon
- Owner: daybrush
- License: mit
- Created: 2019-04-11T14:39:44.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-29T12:21:07.000Z (7 months ago)
- Last Synced: 2025-02-14T04:08:11.550Z (7 days ago)
- Language: TypeScript
- Homepage:
- Size: 1.32 MB
- Stars: 42
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# keycon [](https://badge.fury.io/js/keycon)
Keyboard Controller
* [API Documentation](https://daybrush.com/keycon/release/latest/doc/)
### Frameworks
* [React](https://github.com/daybrush/keycon/tree/master/packages/react-keycon)
* [Vue2](https://github.com/daybrush/keycon/tree/master/packages/vue2-keycon)
* [Vue3](https://github.com/daybrush/keycon/tree/master/packages/vue-keycon)
* [Svelte](https://github.com/daybrush/keycon/tree/master/packages/svelte-keycon)## Installation
```
npm i keycon
```
```html```
## How to use
```js
import KeyController, { getCombi, getKey } from "keycon";const keycon = new KeyController();
// The focus went out of the browser.
keycon.on("blur", () => {
console.log("blur");
});
// keydown all
keycon.keydown(e => {
console.log(e);
});
// keydown space
keycon.keydown("space", e => {
console.log(e);
});
// keydown alt + space combination
keycon.keydown(["alt", "space"], e => {
// ["alt", "space"]
console.log(getCombi(e));
// "space"
console.log(getKey(e.keyCode));console.log(e);
});// keyup all
keycon.keyup(e => {
console.log(e);
});
// keyup space
keycon.keydown("space", e => {
console.log(e);
});
// keyup alt + space combination
keycon.keyup(["alt", "space"], e => {
console.log(e);
});
```