# keycon

> Keyboard Controller

Latest version **1.4.0** (published 2022-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install keycon
pnpm add keycon
yarn add keycon
bun add keycon
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2022-12-04 |
| First published | 2019-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 208.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Daybrush |
| Maintainers | younkue |
| Keywords | key, keycode, keyboard, component, esm |

## Links

- npm: https://www.npmjs.com/package/keycon
- Repository: https://github.com/daybrush/keycon
- Homepage: https://github.com/daybrush/keycon#readme
- Issues: https://github.com/daybrush/keycon/issues
- npm.io page: https://npm.io/package/keycon

## Dependencies (4)

- [keycode](https://npm.io/package/keycode.md) ^2.2.0
- [@cfcs/core](https://npm.io/package/@cfcs/core.md) ^0.0.6
- [@daybrush/utils](https://npm.io/package/@daybrush/utils.md) ^1.7.1
- [@scena/event-emitter](https://npm.io/package/@scena/event-emitter.md) ^1.0.2

## Recent versions

- 1.4.0 (latest) — 2022-12-04
- 1.3.2 — 2022-10-19
- 1.3.1 — 2022-09-24
- 1.3.0 — 2022-09-24
- 1.2.2 — 2022-07-23
- 1.2.1 — 2022-07-23
- 1.2.0 — 2022-07-02
- 1.1.2 — 2020-10-18
- 1.1.1 — 2020-10-17
- 1.1.0 — 2020-08-28
- 1.0.0 — 2020-08-21
- 0.8.0 — 2020-01-02
- 0.7.1 — 2019-12-31
- 0.7.0 — 2019-12-31
- 0.6.0 — 2019-10-05
- … 14 more at https://npm.io/package/keycon/versions

## README

# keycon  [![npm version](https://badge.fury.io/js/keycon.svg)](https://badge.fury.io/js/keycon) 

Keyboard Controller

* [API Documentation](https://daybrush.com/keycon/release/latest/doc/)


## Installation
```
npm i keycon
```
```html
<script src="https://daybrush.com/keycon/release/latest/dist/keycon.min.js"></script>
```


## 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);
});
```

---
_Source: https://npm.io/package/keycon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
