keyboard-mouse-share
v1.0.4
Published
Share keyboard and mouse between Mac and Windows
Maintainers
Readme
Keyboard & Mouse Share (KMS) - Node.js Version
Share your keyboard and mouse between Mac and Windows seamlessly over your local network.
Features
- 🖱️ Share Keyboard & Mouse - Control multiple machines with one set of peripherals
- 🔄 Cross-Platform - Works between Mac and Windows
- ⌨️ Hotkey Switching - Toggle control with
Ctrl+=(configurable) - 🌐 Network-Based - Works over local network (WiFi/Ethernet)
- 🎯 Simple CLI - Easy to configure and use
- ⚡ High Performance - Built on Node.js for efficient async I/O
Installation
From npm (coming soon)
npm install -g keyboard-mouse-shareFrom Source
cd kms-node
npm install
npm linkRequirements
- Node.js 16.0.0 or higher (tested on v16, v18, v20, v22)
- Administrator/root privileges (required for keyboard/mouse control)
- Both machines must be on the same network
Platform-Specific Setup
Windows:
- Run terminal as Administrator
- No additional dependencies needed (nut.js provides pre-built binaries)
Mac:
- Grant Accessibility permissions:
- System Preferences → Security & Privacy → Privacy → Accessibility
- Add Terminal (or your terminal app)
- No build tools required (nut.js provides pre-built binaries)
Linux:
- Install X11 dependencies:
sudo apt-get install libxtst-dev libpng++-dev
Quick Start
Setup Master Machine (Server)
The master machine is the one whose keyboard and mouse you want to share.
# Initialize as server
kms init --mode server --port 5555
# Start the server
kms startSetup Client Machine
The client machine will receive and reproduce the keyboard/mouse events.
# Initialize as client (replace with your server's IP)
kms init --mode client --host 192.168.1.10 --port 5555
# Start the client
kms startUsage
Commands
# Initialize configuration
kms init --mode [server|client] --host <ip> --port <port>
# Start KMS service
kms start
# Show current configuration
kms status
# Change hotkey combination
kms set-hotkey "CTRL + SHIFT + K"
# Reset configuration
kms reset
# Show version
kms --version
# Show help
kms --helpHotkey Control
By default, press Ctrl+= on the server to toggle between:
- Enabled: Server's input is captured and sent to client
- Disabled: Server operates normally (no sharing)
You can customize the hotkey:
kms set-hotkey "CTRL + SHIFT + S"Note: Use = instead of + in the hotkey combination (keyboard limitation).
Network Setup
Find your server's IP address:
- Windows:
ipconfig - Mac/Linux:
ifconfigorip addr
- Windows:
Ensure port is open:
- Default port: 5555
- Configure firewall to allow incoming connections on this port
Architecture
┌─────────────────┐ Network ┌─────────────────┐
│ Master (Server)│ ───────────────> │ Client │
│ │ │ │
│ Captures input │ Sends events (JSON) │ Reproduces │
│ + Hotkey │ over TCP socket │ input events │
└─────────────────┘ └─────────────────┘Configuration
Configuration is stored in ~/.kms/config.json:
{
"mode": "server",
"port": 5555,
"host": null,
"hotkey": "CTRL + =",
"logLevel": "INFO"
}Troubleshooting
Installation Issues
nut.js installation fails:
- Ensure you're using Node.js 16.0.0 or higher
- On Linux, install X11 dependencies:
sudo apt-get install libxtst-dev libpng++-dev - nut.js provides pre-built binaries for most platforms (no compilation needed)
Connection Issues
- Ensure both machines are on the same network
- Check firewall settings (port 5555 must be open)
- Verify server IP address is correct
Permission Errors
- Windows: Run as Administrator
- Mac: Grant Accessibility permissions in System Preferences
- Linux: Run with sudo
Hotkey Not Working
- Requires administrator/root privileges
- Try a different key combination
- Check if another application is using the same hotkey
Performance
Node.js version benefits:
- ✅ Asynchronous I/O for better network performance
- ✅ Non-blocking event loop
- ✅ Lower latency compared to Python (typically < 5ms)
- ✅ Efficient memory usage
- ✅ Pre-built binaries (no compilation needed with nut.js)
Limitations
- No encryption in v0.1 (use on trusted networks only)
- Single client connection at a time
- Input capture uses polling (60fps) - future versions will use native hooks
Roadmap
- [ ] Native event hooks (replace polling)
- [ ] Multi-client support
- [ ] Clipboard sharing
- [ ] Encryption for secure transmission
- [ ] GUI interface
- [ ] Auto-discovery of devices on network
- [ ] File transfer support
- [ ] Pre-built binaries (no compilation needed)
Comparison: Node.js vs Python
| Feature | Node.js | Python | |---------|---------|--------| | Network I/O | Faster (async native) | Good | | Installation | Pre-built binaries (nut.js) | No compilation | | Performance | ~5-10ms latency | ~10-15ms latency | | Memory | Lower | Higher | | Maturity | nut.js modern & maintained | pynput very stable | | Node.js Support | v16-v22+ ✅ | N/A |
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details
Acknowledgments
Built with:
- @nut-tree/nut-js - Modern desktop automation (v4+)
- node-global-key-listener - Global hotkey detection
- commander - CLI framework
- chalk - Terminal styling
