https://github.com/sidneys/specialkey-emulator
Emulate special keys (e.g. brightness, play/pause, increase volume) by emitting low-level global keyboard events - using NodeJS.
https://github.com/sidneys/specialkey-emulator
Last synced: 10 months ago
JSON representation
Emulate special keys (e.g. brightness, play/pause, increase volume) by emitting low-level global keyboard events - using NodeJS.
- Host: GitHub
- URL: https://github.com/sidneys/specialkey-emulator
- Owner: sidneys
- License: mit
- Created: 2015-10-07T04:20:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-07-28T20:47:45.000Z (almost 8 years ago)
- Last Synced: 2025-04-08T22:47:17.799Z (about 1 year ago)
- Language: JavaScript
- Size: 45.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# specialkey-emulator
___
**Emulate special keys (e.g. brightness, play/pause, increase volume) by emitting low-level global keyboard events - using NodeJS.**
Contents
----
1. [Supported Platforms](#supported-platforms)
1. [Requirements](#requirements)
1. [Roadmap](#roadmap)
1. [Installation](#installation)
1. [Usage](#usage)
1. [API](#api)
1. [List of Special Key Names](#list-of-special-key-names)
1. [Author](#author)
1. [License](#license)
Currently OSX only (see [Roadmap](#roadmap)).
Tested on OSX 10.13 and 10.14.
Node 10.0.0+
Roadmap
----
- Windows version, see [Virtual Keycodes (Microsoft Developer Network)](https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731.aspx)
```sh
npm install specialkey-emulator --save
```
To trigger a key, simply require the module and directly call it with the name of the key to be triggered. See [List of Special Key Names](#list-of-special-key-names) for a list of currently supported keys.
### Simple usage
```javascript
specialkey = require('specialkey-emulator');
specialkey('NX_KEYTYPE_ILLUMINATION_DOWN')
```
### Callback usage
```javascript
specialkey = require('specialkey-emulator');
specialkey('NX_KEYTYPE_ILLUMINATION_DOWN', function (err, result) {
if (err) {
return console.log('Error', err);
}
console.log('Key triggered', result);
})
```
### Overview
This module directly exports itself as a function:
```javascript
require('specialkey-emulator')(keyName, callback)
```
### Parameters
It takes the following parameters:
- **keyName** (String) - Name of the key to be triggered. See [List of Special Key Names](#list-of-special-key-names).
- **callback** (Function) - Called after trying to trigger the special key.
- error (Error) - Error
- result (Number) - Internal code of the key which was called.
List of Special Key Names
----
### OSX
- Reference: [Darwin Keyboard Events @ opensource.apple.com](http://www.opensource.apple.com/source/IOHIDFamily/IOHIDFamily-86.1/IOHIDSystem/IOKit/hidsystem/ev_keymap.h)
- Names
- NX\_KEYTYPE\_SOUND\_UP
- NX\_KEYTYPE\_SOUND\_DOWN
- NX\_KEYTYPE\_BRIGHTNESS\_UP
- NX\_KEYTYPE\_BRIGHTNESS\_DOWN
- NX\_KEYTYPE\_CAPS\_LOCK
- NX\_KEYTYPE\_HELP
- NX\_KEYTYPE\_POWER\_KEY
- NX\_KEYTYPE\_MUTE
- NX\_KEYTYPE\_UP\_ARROW\_KEY
- NX\_KEYTYPE\_DOWN\_ARROW\_KEY
- NX\_KEYTYPE\_NUM\_LOCK
- NX\_KEYTYPE\_CONTRAST\_UP
- NX\_KEYTYPE\_CONTRAST\_DOWN
- NX\_KEYTYPE\_LAUNCH\_PANEL
- NX\_KEYTYPE\_EJECT
- NX\_KEYTYPE\_VIDMIRROR
- NX\_KEYTYPE\_PLAY
- NX\_KEYTYPE\_NEXT
- NX\_KEYTYPE\_PREVIOUS
- NX\_KEYTYPE\_FAST
- NX\_KEYTYPE\_REWIND
- NX\_KEYTYPE\_ILLUMINATION\_UP
- NX\_KEYTYPE\_ILLUMINATION\_DOWN
- NX\_KEYTYPE\_ILLUMINATION\_TOGGLE
Author
----
[sidneys.github.io](http://sidneys.github.io) 2018
MIT