# Dokkey
**Dokkey** is a lightweight Python package designed to detect key presses on Windows. It captures keyboard input and returns the ASCII code of the key pressed. This package has been tested on **Windows 11**.
---
## Features
- Detects keypresses on Windows.
- Returns the ASCII code of the key pressed.
- Lightweight and easy to integrate into your projects.
---
## Requirements
- Python 3.7 or higher
- Windows OS (Tested on Windows 11)
---
## Installation
Install the package using pip:
```bash
pip install dokkey
```
## Usage
Here is an example of how to use Dokkey:
```python
import signal
import dokkey
def cleanup_and_exit(signum, frame):
try:
dokkey.uninstall_hook()
except Exception as e:
print(f">>> Error during cleanup: {e}")
finally:
print(">>> Exiting gracefully.")
exit(0)
signal.signal(signal.SIGINT, cleanup_and_exit)
# Install the hook and run the message loop
def on_key_press(key_code):
print(f">>> Key pressed: {key_code}")
print("Listening for key presses. Press Ctrl+C to stop.")
try:
dokkey.install_hook(on_key_press)
dokkey.run_message_loop()
except Exception as e:
print(f">>> Error: {e}")
finally:
dokkey.uninstall_hook()
```
## Output Example
```plaintext
Listening for key presses. Press Ctrl+C to stop.
Key pressed: 65 # (A key)
Key pressed: 98 # (b key)
```
## How It Works
Dokkey leverages Windows APIs to capture global keyboard events and converts the input to ASCII codes. It ensures minimal interference with other running applications.
## Limitations
This package works only on Windows.
It may require administrator privileges for certain use cases.
## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.
## Local Development
To set up a local development environment, follow these steps:
1. Create and activate a virtual environment:
```bash
python -m venv venv
venv/Scripts/activate
```
2. Build & install the project
```bash
python setup.py build
python setup.py install
```
The module is now installed in the virtual environment. You can test it by running the example script:
```bash
python examples/example.py
```
## License
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.
## Author
Developed by Sekiraw
## Acknowledgements
Thanks to the Python and Windows development communities for providing tools and resources to make this project possible.
```vbnet
This styling ensures clarity, proper sectioning, and good readability. Let me know if you`d like any further adjustments!
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Sekiraw/Dokkey",
"name": "dokkey",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "KEY, TRACK",
"author": "Qiyaya",
"author_email": "v2020.bohus.peter@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/c2/a6/eb3b0a1069645f48691f72f09094fbfec954c2831817da1f2b378558c1de/dokkey-1.2.2.tar.gz",
"platform": null,
"description": "# Dokkey\r\n\r\n**Dokkey** is a lightweight Python package designed to detect key presses on Windows. It captures keyboard input and returns the ASCII code of the key pressed. This package has been tested on **Windows 11**.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- Detects keypresses on Windows.\r\n- Returns the ASCII code of the key pressed.\r\n- Lightweight and easy to integrate into your projects.\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- Python 3.7 or higher\r\n- Windows OS (Tested on Windows 11)\r\n\r\n---\r\n\r\n## Installation\r\n\r\nInstall the package using pip:\r\n\r\n```bash\r\npip install dokkey\r\n```\r\n\r\n## Usage\r\nHere is an example of how to use Dokkey:\r\n\r\n```python\r\nimport signal\r\nimport dokkey\r\n\r\ndef cleanup_and_exit(signum, frame):\r\n try:\r\n dokkey.uninstall_hook()\r\n except Exception as e:\r\n print(f\">>> Error during cleanup: {e}\")\r\n finally:\r\n print(\">>> Exiting gracefully.\")\r\n exit(0)\r\n\r\nsignal.signal(signal.SIGINT, cleanup_and_exit)\r\n\r\n# Install the hook and run the message loop\r\ndef on_key_press(key_code):\r\n print(f\">>> Key pressed: {key_code}\")\r\n\r\nprint(\"Listening for key presses. Press Ctrl+C to stop.\")\r\ntry:\r\n dokkey.install_hook(on_key_press)\r\n dokkey.run_message_loop()\r\nexcept Exception as e:\r\n print(f\">>> Error: {e}\")\r\nfinally:\r\n dokkey.uninstall_hook()\r\n```\r\n## Output Example\r\n```plaintext\r\nListening for key presses. Press Ctrl+C to stop.\r\nKey pressed: 65 # (A key)\r\nKey pressed: 98 # (b key)\r\n```\r\n\r\n## How It Works\r\nDokkey leverages Windows APIs to capture global keyboard events and converts the input to ASCII codes. It ensures minimal interference with other running applications.\r\n\r\n## Limitations\r\nThis package works only on Windows.\r\nIt may require administrator privileges for certain use cases.\r\n\r\n## Contributing\r\nContributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.\r\n\r\n## Local Development\r\nTo set up a local development environment, follow these steps:\r\n\r\n1. Create and activate a virtual environment:\r\n ```bash\r\n python -m venv venv\r\n venv/Scripts/activate\r\n ```\r\n2. Build & install the project\r\n ```bash\r\n python setup.py build\r\n python setup.py install\r\n ```\r\nThe module is now installed in the virtual environment. You can test it by running the example script:\r\n\r\n```bash\r\npython examples/example.py\r\n```\r\n\r\n\r\n## License\r\nThis project is licensed under the Apache-2.0 License. See the LICENSE file for details.\r\n\r\n## Author\r\nDeveloped by Sekiraw\r\n\r\n## Acknowledgements\r\nThanks to the Python and Windows development communities for providing tools and resources to make this project possible.\r\n\r\n```vbnet\r\nThis styling ensures clarity, proper sectioning, and good readability. Let me know if you`d like any further adjustments!\r\n```\r\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Dokkey is a Python package designed to detect keypresses on Windows",
"version": "1.2.2",
"project_urls": {
"Homepage": "https://github.com/Sekiraw/Dokkey"
},
"split_keywords": [
"key",
" track"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7f6de0e3b5112d3d74aee614829986b019094e8ae58f683d472b37e3f3239d7c",
"md5": "9329d177386830bcdb774035dae5b7e3",
"sha256": "7f1f8a5a465cf5d698cfddd28e58b31ae44c680ae15b5f044f02fdfbe17ed99b"
},
"downloads": -1,
"filename": "dokkey-1.2.2-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "9329d177386830bcdb774035dae5b7e3",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": null,
"size": 12471,
"upload_time": "2025-01-19T15:16:58",
"upload_time_iso_8601": "2025-01-19T15:16:58.554507Z",
"url": "https://files.pythonhosted.org/packages/7f/6d/e0e3b5112d3d74aee614829986b019094e8ae58f683d472b37e3f3239d7c/dokkey-1.2.2-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c2a6eb3b0a1069645f48691f72f09094fbfec954c2831817da1f2b378558c1de",
"md5": "799f53dc827ee272ad03a3baaeb0d90a",
"sha256": "cf5eea87735d5904ea5f3f2d515b5321cf8786d64800425532a4dd7a786609e1"
},
"downloads": -1,
"filename": "dokkey-1.2.2.tar.gz",
"has_sig": false,
"md5_digest": "799f53dc827ee272ad03a3baaeb0d90a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7508,
"upload_time": "2025-01-19T15:17:00",
"upload_time_iso_8601": "2025-01-19T15:17:00.175515Z",
"url": "https://files.pythonhosted.org/packages/c2/a6/eb3b0a1069645f48691f72f09094fbfec954c2831817da1f2b378558c1de/dokkey-1.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-19 15:17:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Sekiraw",
"github_project": "Dokkey",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "dokkey"
}