https://github.com/developer239/macos-keyboard-mouse
Native Keyboard and Mouse controls for your Node application.
https://github.com/developer239/macos-keyboard-mouse
Last synced: about 1 year ago
JSON representation
Native Keyboard and Mouse controls for your Node application.
- Host: GitHub
- URL: https://github.com/developer239/macos-keyboard-mouse
- Owner: developer239
- License: mit
- Created: 2021-11-20T11:35:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T01:13:32.000Z (almost 3 years ago)
- Last Synced: 2025-02-05T04:16:59.061Z (about 1 year ago)
- Language: C++
- Homepage:
- Size: 94.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Since both RobotJS libraries are no longer being maintained, and as I had been working with C++ in the past month, I decided to start a new, more robust implementation. [I have implemented keyboard, mouse, and display controls that are very similar to the original RobotJS API 🤖developer239/robot-ts](https://github.com/developer239/robot-ts) (and should be cross-platform in the future)
# MacOS Keyboard Mouse
[](https://www.npmjs.com/package/macos-keyboard-mouse "View this project on npm")
Keyboard and mouse controls for your Node project. Currently, only supports Mac.
## Libraries:
- [node-addon-api](https://github.com/nodejs/node-addon-api) - interface for building native addons
- [cmake-js](https://github.com/cmake-js/cmake-js) - native addon build tool
## Example
### Mouse
```js
import { Mouse, Button } from 'macos-keyboard-mouse';
const mouse = new Mouse();
// sets delay between pixels
mouse.setDelay(16);
// moves mouse to x: 100, y: 100
mouse.move(100, 100);
// presses left mouse key
mouse.pressLeft();
// presses right mouse key
mouse.pressRight();
// gets current mouse position
mouse.getLocation();
// holds left mouse button down
mouse.press(Button.left, false);
// holds right mouse button down
mouse.press(Button.right, false);
```
### Keyboard
```js
import { Keyboard } from 'macos-keyboard-mouse';
const keyboard = new Keyboard();
// types 'hello world'
keyboard.type('Hello world');
// types 'm'
keyboard.click('m');
// presses "enter" key
keyboard.clickEnter();
```