# touchkey

> Touch Keypad lib for QT1070.

Latest version **1.0.1** (published 2019-10-18) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-10-18 |
| First published | 2019-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nico De Witte |
| Maintainers | bioboost |
| Keywords | touch, qt1070 |

## Links

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

## Dependencies (3)

- [onoff](https://npm.io/package/onoff.md) ^4.1.3
- [qt1070](https://npm.io/package/qt1070.md) ^1.0.0
- [i2c-bus](https://npm.io/package/i2c-bus.md) ^4.0.10

## Recent versions

- 1.0.1 (latest) — 2019-10-18
- 1.0.0 — 2019-09-06

## README

# Touch Key

NodeJS Touch Keypad lib for QT1070.

Turns the QT1070 into a small keypad with key events.

Just subscribe to any of the events:

* `keydown`: to get notified when a key is pressed
* `keyup`: to get notified when a key is released
* `keychange`: to get notified when a key is pressed or released

The event object contains both the `key` (0 to 6) and `state` (`'pressed'` or `'released'`). For example:

```js
{
  key: 1,
  state: 'pressed'
}
```

You can also read the current state of the keys using the method `key_states()` which returns an array of all keys in the format shown above.

## Dependencies

This library makes use of:

* [qt1070](https://www.npmjs.com/package/qt1070) a driver library to interact with the QT1070
* [i2c-bus](https://www.npmjs.com/package/i2c-bus) to communicate with i2c devices
* [onoff](https://www.npmjs.com/package/onoff) to detect the interrupts coming from the QT1070 chip

## Example

The i2c object needs to be injected via the constructor.

A basic example:

```js
const TouchKey = require('touchkey');
const i2c = require('i2c-bus');

const i2c1 = i2c.open(1, (err) => {
  if (err) throw err;
  console.log("Opened i2c bus successfully");

  let keypad = new TouchKey(i2c1);

  keypad.on('keychange', (event) => {
    console.log("Getting keychange event " + JSON.stringify(event));
  });

  keypad.on('keydown', (event) => {
    console.log("Getting keydown event " + JSON.stringify(event));
  });

  keypad.on('keyup', (event) => {
    console.log("Getting keyup event " + JSON.stringify(event));
  });

});
```

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