Chrome Native Messaging host that simulates OS-level keystrokes and mouse clicks
Project description
Keystroke Sender
A Chrome Native Messaging host that simulates OS-level keystrokes. Receives text strings from a Chrome extension and types them out as real key presses using pynput.
Works on macOS, Linux, and Windows.
Companion extension: Chrome Form Filler (dpdolkkncejkelemckjmjoaefmgdhepj)
Prerequisites
- Python 3.7+
- pip
- Google Chrome
- Chrome Form Filler extension
Installation
pip install (recommended)
pip install keystroke-sender
Then register the Chrome native messaging host:
keystroke-sender-register YOUR_EXTENSION_ID
To unregister later:
keystroke-sender-register --unregister
Manual install (macOS / Linux)
chmod +x install.sh
./install.sh
Manual install (Windows)
install.bat
The manual installer will:
- Prompt you for your Chrome extension ID (find it at
chrome://extensions) - Create the native messaging host manifest in the correct OS location
- Install the
pynputPython dependency
macOS Accessibility Permission
On macOS, you must grant Accessibility permission to your terminal app (or Python) for keystroke simulation to work:
System Preferences > Privacy & Security > Accessibility — add your terminal app (Terminal, iTerm2, etc.).
Usage
From a Chrome extension, send a message to the native host:
chrome.runtime.sendNativeMessage(
"com.propdream.keystroke_sender",
{ text: "Hello, world!" },
(response) => {
console.log(response);
// { status: "ok", typed: 13 }
}
);
Message Format
Request:
{
"text": "string to type",
"delay": 0.05
}
text(required): The string to type as OS-level keystrokes.delay(optional): Seconds between each keystroke. Default:0.05.
Response:
{ "status": "ok", "typed": 13 }
or on error:
{ "status": "error", "message": "description" }
Extension Setup
Add "nativeMessaging" to your extension's manifest.json permissions:
{
"permissions": ["nativeMessaging"]
}
Uninstallation
macOS / Linux
chmod +x uninstall.sh
./uninstall.sh
Windows
uninstall.bat
Security
This app simulates real keystrokes and mouse clicks at the OS level, so it includes several safeguards to prevent misuse:
Chrome Native Messaging isolation — The host process can only be launched by Chrome, and only the extension ID you registered in allowed_origins can send it messages. No network socket is opened; communication is purely via stdin/stdout. An unauthorized extension or external program cannot talk to it.
Idle timeout — The host automatically exits after 1 minute of inactivity. It does not stay running indefinitely.
Rate limiting — A maximum of 100 actions per second is enforced. Bursts beyond this are rejected with an error response.
Input size limits — Messages larger than 1 MB are rejected before parsing. Text payloads longer than 10,000 characters are rejected before typing.
| Limit | Default |
|---|---|
| Idle timeout | 60 s (1 min) |
| Rate limit | 100 actions / 1 s |
| Max message size | 1 MB |
| Max text length | 10,000 chars |
These constants are defined at the top of src/keystroke_sender/host.py and can be adjusted if needed.
Debugging
- Launch Chrome from the terminal to see native host stderr output
- Use
chrome://extensions> Service Worker > Console to see extension-side errors - Check
chrome.runtime.lastErrorin thesendNativeMessagecallback
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keystroke_sender-0.1.1.tar.gz.
File metadata
- Download URL: keystroke_sender-0.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3622e1eb1166e67f11351b79383c475f19c49304d9dc0b61dbae48b51415818
|
|
| MD5 |
e7abb2a91ce01731d0c40f57ec8b7ec6
|
|
| BLAKE2b-256 |
9abe0e87017706dba13416d9743875858134c6460b0938ad87b00c7cd5feb2f3
|
Provenance
The following attestation bundles were made for keystroke_sender-0.1.1.tar.gz:
Publisher:
publish.yml on PropDream/keystroke-sender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keystroke_sender-0.1.1.tar.gz -
Subject digest:
c3622e1eb1166e67f11351b79383c475f19c49304d9dc0b61dbae48b51415818 - Sigstore transparency entry: 971919424
- Sigstore integration time:
-
Permalink:
PropDream/keystroke-sender@dd27419709d133fcc663daed27b25f340e81df73 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/PropDream
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd27419709d133fcc663daed27b25f340e81df73 -
Trigger Event:
release
-
Statement type:
File details
Details for the file keystroke_sender-0.1.1-py3-none-any.whl.
File metadata
- Download URL: keystroke_sender-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
220088618797dc69bb840e52f155ed3976b8bd04e12fa478c8100f9e001724a1
|
|
| MD5 |
f23748634387f4217765cacfd3e3c348
|
|
| BLAKE2b-256 |
f57e2c09e82c98c22dcd2b47a6f9999294dfdcc2257b190d4525ffeb53afe4cf
|
Provenance
The following attestation bundles were made for keystroke_sender-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on PropDream/keystroke-sender
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keystroke_sender-0.1.1-py3-none-any.whl -
Subject digest:
220088618797dc69bb840e52f155ed3976b8bd04e12fa478c8100f9e001724a1 - Sigstore transparency entry: 971919542
- Sigstore integration time:
-
Permalink:
PropDream/keystroke-sender@dd27419709d133fcc663daed27b25f340e81df73 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/PropDream
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd27419709d133fcc663daed27b25f340e81df73 -
Trigger Event:
release
-
Statement type: