Emulate special keys (e.g. brightness, play/pause, increase volume) by emitting low-level global keyboard events - using NodeJS.
- Supported Platforms
- Requirements
- Roadmap
- Installation
- Usage
- API
- List of Special Key Names
- Author
- License
Currently OSX only (see Roadmap).
Tested on OSX 10.10 and 10.11.
Node 4.0.0+
- Windows version, see �Virtual Keycodes (Microsoft Developer Network)
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 for a list of currently supported keys.
specialkey = require('specialkey-emulator');
specialkey('NX_KEYTYPE_ILLUMINATION_DOWN')
specialkey = require('specialkey-emulator');
specialkey('NX_KEYTYPE_ILLUMINATION_DOWN', function (err, result) {
if (err) {
return console.log('Error', err);
}
console.log('Key triggered', result);
})
This module directly exports itself as a function:
require('specialkey-emulator')(keyName, callback)
It takes the following parameters:
- keyName (String) - Name of the key to be triggered. See 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.
- Reference: Darwin Keyboard Events �@ opensource.apple.com
- 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
Sidney Bofah
MIT