# keycodes-to-ps2-scan-codes

> Convert Web API `keyCode`s to PS/2 keyboard scan codes (set 2).

Latest version **1.0.1** (published 2020-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install keycodes-to-ps2-scan-codes
pnpm add keycodes-to-ps2-scan-codes
yarn add keycodes-to-ps2-scan-codes
bun add keycodes-to-ps2-scan-codes
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-08-14 |
| First published | 2020-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Zach Bloomquist |
| Maintainers | flotwig |
| Keywords | ps/2, keyboard, scan, codes |

## Links

- npm: https://www.npmjs.com/package/keycodes-to-ps2-scan-codes
- Repository: https://github.com/flotwig/keycodes-to-ps2-scan-codes
- Homepage: https://github.com/flotwig/keycodes-to-ps2-scan-codes#readme
- Issues: https://github.com/flotwig/keycodes-to-ps2-scan-codes/issues
- npm.io page: https://npm.io/package/keycodes-to-ps2-scan-codes

## Recent versions

- 1.0.1 (latest) — 2020-08-14
- 1.0.0 — 2020-08-13

## README

keycodes-to-ps2-scan-codes
===

Convert Web API `keyCode`s to PS/2 keyboard scan codes (set 2).

Referenced from http://www.vetra.com/scancodes.html

# Installation

```
npm i --save keycodes-to-ps2-scan-codes
```

# Exports

## `getMakeBytes(keyCode: string): number[]`

* Returns: a byte array to "make" the keypress for the specified `keyCode`. Throws if the `keyCode` is not mapped.
* Example:
    ```js
    const { getMakeBytes } = require('keycodes-to-ps2-scan-codes')
    getMakeBytes('KeyA') // [ 0x1C ]
    getMakeBytes('End') // [ 0xE0, 0x69 ]
    getMakeBytes('IntlRo') // throws - IntlRo is a valid `keyCode`, but it is not mappable to PS/2
    ```

## `getBreakBytes(keyCode: string): number[]`

* Returns: a byte array to "break" the keypress for the specified `keyCode`. Throws if the `keyCode` is not mapped.
* Example:
    ```js
    const { getBreakBytes } = require('keycodes-to-ps2-scan-codes')
    getBreakBytes('KeyA') // [ 0xF0, 0x1C ]
    getBreakBytes('End') // [ 0xE0, 0xF0, 0x69 ]
    getBreakBytes('IntlRo') // throws - IntlRo is a valid `keyCode`, but it is not mappable to PS/2
    ```

## `keysToScanCodes: { [scanCode: string]: [number[], number[]] }`

* Maps keyCodes to pairs of byte arrays, corresponding to the respective "make" and "break" commands.
* Example:
    ```js
    const { keysToScanCodes } = require('keycodes-to-ps2-scan-codes')
    keysToScanCodes['KeyA'] // [ [ 0x1C ], [ 0xF0, 0x1C ] ]
    ```

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