# key-mapping

> store key mappings

Latest version **1.2.1** (published 2023-09-11) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install key-mapping
pnpm add key-mapping
yarn add key-mapping
bun add key-mapping
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2023-09-11 |
| First published | 2023-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | 18 |
| Dependencies | 0 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (Unknown) |
| GitHub stars | 0 |
| Author | sasa+1 |
| Maintainers | sasaplus1 |

## Links

- npm: https://www.npmjs.com/package/key-mapping
- Repository: https://github.com/sasaplus1/key-mapping.js
- Homepage: https://github.com/sasaplus1/key-mapping.js#readme
- Issues: https://github.com/sasaplus1/key-mapping.js/issues
- npm.io page: https://npm.io/package/key-mapping

## Recent versions

- 1.2.1 (latest) — 2023-09-11
- 1.2.0 — 2023-09-09
- 1.1.0 — 2023-09-08
- 1.0.0 — 2023-09-08
- 0.1.2 — 2023-09-08
- 0.1.1 — 2023-09-08
- 0.1.0 — 2023-09-07

## README

# key-mapping

store key mappings

## Usage

```ts
import { createKeyMappingNode } from 'key-mapping';

const root = createKeyMappingNode({ key: '' });

root.add({ key: 'A' }).add({
  key: 'B',
  action() {
    console.log('Hello!');
  }
});

root.get('A')?.get('B')?.mapping?.action?.(); // => Hello!
```

or

```ts
import {
  createKeyMappingNode,
  addKeyMappings,
  getKeyMappingNode
} from 'key-mapping';

const root = createKeyMappingNode({ key: '' });

const keyMappings = [
  { key: 'A' },
  {
    key: 'B',
    action() {
      console.log('Hello!');
    }
  }
];

addKeyMappings(keyMappings, root);
getKeyMappingNode(['A', 'B'], root)?.mapping?.action?.(); // => Hello!
```

## License

The MIT license

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