Skip to content

About

Node.js library mapping Linux input-event key codes to key names/characters; already published on npm as `linux-key-info`.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

node-linux-key-info

A simple utility for getting key info for a given Linux key code (as emitted by /dev/input/eventX). Published on npm as linux-key-info.

Archived — this project is no longer maintained, but the npm package remains published and usable.

Install

npm i --save linux-key-info

Usage

const { keyCodeInfo, listAllKnownKeys } = require('linux-key-info');

console.log(keyCodeInfo(30).name); // 'A'
console.log(keyCodeInfo(1).name);  // 'ESC'
console.log(listAllKnownKeys());   // all ~145 known keys

Pairs well with the input-event package for reading raw keyboard events on Linux:

const InputEvent = require('input-event');
const { keyCodeInfo } = require('linux-key-info');

const input = new InputEvent('/dev/input/event0');
const keyboard = new InputEvent.Keyboard(input);

keyboard.on('keypress', (event) => {
  const info = keyCodeInfo(event.code);
  console.log(`Key pressed: code=${event.code}, name="${info.name}", char="${info.char}"`);
});

Tech

Plain Node.js (CommonJS), no runtime dependencies. Built with webpack 4; tested with mocha/chai.

Note

package.json on this branch is at 1.0.1; npm's published latest is 1.0.2 (a version-only bump made from a tag that was never merged back to master). The code is identical between the two — cosmetic only.

License

MIT

About

Node.js library mapping Linux input-event key codes to key names/characters; already published on npm as `linux-key-info`.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages