npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-interception

v2.0.4

Published

A windows library for intercepting and controlling keyboards and mouses with multiple devices support.

Downloads

55

Readme

node-interception

GitHub NPM License Documentation Discord Dependabot

A windows library for intercepting and controlling keyboards and mouses with multiple devices support.

The package provides Node.js bindings for the original Interception library by Oblitum, and supports it with a wrapper and TypeScript definitions.

Example

// Increase the process priority to prevent input lagging.
import * as os from 'os';
os.setPriority(os.constants.priority.PRIORITY_HIGH);

import { Interception, FilterKeyState, FilterMouseState } from 'node-interception';
const interception = new Interception();

// Display the list of available devices.
console.log('Devices:', interception.getDevices().map(device => `${device}`));

// Enable the capturing of all strokes.
interception.setFilter('keyboard', FilterKeyState.ALL);
interception.setFilter('mouse', FilterMouseState.ALL);

const SCANCODE_ESC = 0x01;

async function listen() {
    console.info('Press any key or move the mouse to generate strokes.');
    console.info('Press ESC to exit and restore back control.');

    while (true) {
        const device = await interception.wait();
        const stroke = device?.receive();

        if (!device || !stroke || (stroke?.type === 'keyboard' && stroke.code === SCANCODE_ESC)) break;

        console.log(`${device}`, stroke);
    }

    interception.destroy();
}

// Start listening for keyboard and mouse strokes.
listen().catch(console.error);

Features

  • Contains prebuilt binaries for 32-bit (ia32) and 64-bit (x64) Windows machines.
  • Written using N-API and node-addon-api so it should work with different node versions and electron without rebuilding.
  • Written in TypeScript to provide enhanced IDE support.
  • Allows working with each mouse and keyboard as independent devices, so different logic can be used for each keyboard/mouse.
  • Allows blocking or modifying the devices strokes.

Interception use cases

As the original library author (Oblitum) written:

Interception has been used around the world in cases I couldn't imagine when I first created it:

  • Helping people with accessibility limitations, tailoring systems according to their limitations.
  • By companies in aviation training, to connect many devices at once and customizing each one.
  • By companies providing SCADA (supervisory control and data acquisition) solutions.
  • In game applications like BOTs and control customization.
  • To construct an emacs mode of the system.
  • To customize supermarket cashier's systems.
  • In doctoral thesis about typing pattern recognition for security applications.
  • Home theater automation.
  • ...

Documentation

The API documentation is generated using TypeDoc and available on GitHub Pages.

Community

A small discord server has been created in the hope of finding a community, so please don't hesitate to join it :)

You can ask for help there using the library, share your work, and give suggestions on what improvements can be done!

Installation

Installing the package

yarn add node-interception
rem -- or using npm
npm install node-interception

Installing the driver

Using a command prompt with Administrative Privileges:

npx node-interception /install

You can uninstall it later using /uninstall instead.

You'll need to restart for the driver installation to be complete.

License

The binding and wrapper are licensed under LGPL-3.0-or-later, check the LICENSE file.

The original Interception library is licensed under LGPL-3.0 too for un-commercial usage, and has a seperate license for commercial usage, check it in it's repository.

The package and repository of this module contains a redistribution of the interception library as that's permitted by the LGPL-3.0 license, please create an issue if that's wrong.

Credits

  • Oblitum for creating the original interception library.
  • Rami Sabbagh for writing the binding and wrapper.