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

nodehotkey

v2.0.15

Published

Authotkey like macros for NodeJS

Downloads

63

Readme

GitHub GitHub package.json version

NodeHotKey

https://github.com/Rubinder25/NodeHotKey
https://www.npmjs.com/package/nodehotkey
This is an autohotkey like library for NodeJs

Features

  1. Make global Macros and assign hotkeys to trigger them
  2. Make global hotstrings to expand text as you type it
  3. Catch global keyboard/mouse events in your code
  4. Operate keyboard, mouse and clipboard from code

Usage

Install

npm install nodehotkey --save
follow this page to install dependencies for robot-js on your platform: http://getrobot.net/docs/usage.html

import

import { NodeHotKey } from 'nodehotkey';

Initialize the object

let nhk = new NodeHotKey({});

Currently, we are passing an empty object. A Macro Config object can be passed to the constructor in order to create AutoHotkey like macros. Please refer to the next section for this.

Macro

Macros are pre-defined steps that can be triggered by either pressing hotkeys or typing hotstrings. These can be defined as JavaScript objects.

A sample macro looks like this

let macroConfig = {
    'Name of the Macro': {
		hotkeys: [kc._CONTROL, kc._E],
		steps: [
			{ type: 'This Macro can be triggered by pressing CTRL+E\n' },
			{ type: "Wait for 3 secs then press ','  " },
			{ wait: 3000 },
			{ click: kc._COMMA },
			{ func: tools => { 
				    tools.type('Run JavaScript functions by pressing hotkeys'); 
				} 
			}
		]
	}
}

we can then pass this macroConfig to constructor of NodeHotKey like this:-

let nhk = new NodeHotKey(macroConfig);
nhk.startListening();

For more sample Marco configs check out MacroSamples_NodeHotKey.

Events

nhk.on(nhk.eventTypes.keyPressed, (eventData) => {
    console.log('KeyPressed ', eventData.keyCode);
});

Functions

following are the utility functions present in the package:-

import { pressKey, releaseKey, click,
        type, paste, wait, setClipboardText, 
        getClipboardText, matchCurrentWindowTitle } from 'nodehotkey'; 

Putting it all together

import { NodeHotKey, pressKey,releaseKey, KEYCODES as kc } from 'nodehotkey';

// press key
pressKey(kc._A);
releaseKey(kc._A);

let macroConfig = {
    'Name of the Macro': {
        hotkeys: [kc._CONTROL, kc._E],
        steps: [
            { type: 'This Macro can be triggered by pressing CTRL+E\n' },
            { type: "Wait for 3 secs then press ','  " },
            { wait: 3000 },
            { click: kc._COMMA },
            { func: tools => { 
                        tools.type('Run JavaScript functions by pressing hotkeys'); 
                    } 
            }
        ]
    }
}

let nhk = new NodeHotKey(macroConfig);

nhk.startListening();

nhk.on(nhk.eventTypes.keyPressed, (eventData) => {
    console.log('KeyPressed ', eventData.keyCode);
});

// nhk.stopListening(); // terminates the program

Sample Macros

https://github.com/Rubinder25/MacroSamples_NodeHotKey

email: [email protected]

License

MIT

Note: currently Node V10 is not supported