keycodes-to-ps2-scan-codes
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

keycodes-to-ps2-scan-codes

Convert Web API keyCodes 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:
    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:
    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:
    const { keysToScanCodes } = require('keycodes-to-ps2-scan-codes')
    keysToScanCodes['KeyA'] // [ [ 0x1C ], [ 0xF0, 0x1C ] ]

Readme

Keywords

Package Sidebar

Install

npm i keycodes-to-ps2-scan-codes

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

5.5 kB

Total Files

4

Last publish

Collaborators

  • flotwig