{"id":18789155,"url":"https://github.com/hmasdev/keyboard_monitor_app","last_synced_at":"2025-12-25T23:30:12.695Z","repository":{"id":191537614,"uuid":"683942236","full_name":"hmasdev/keyboard_monitor_app","owner":"hmasdev","description":":keyboard: :eyes: Python application to monitor your keyboard","archived":false,"fork":false,"pushed_at":"2023-09-16T13:36:14.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T14:35:18.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmasdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-28T05:41:01.000Z","updated_at":"2023-08-30T02:32:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"6bd4e7f4-f031-4a34-8aba-58bf43c088c4","html_url":"https://github.com/hmasdev/keyboard_monitor_app","commit_stats":null,"previous_names":["hmasdev/keyboard_monitor_app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmasdev%2Fkeyboard_monitor_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmasdev%2Fkeyboard_monitor_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmasdev%2Fkeyboard_monitor_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmasdev%2Fkeyboard_monitor_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmasdev","download_url":"https://codeload.github.com/hmasdev/keyboard_monitor_app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239709217,"owners_count":19684215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T21:06:49.404Z","updated_at":"2025-12-25T23:30:12.667Z","avatar_url":"https://github.com/hmasdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keyboard Monitor App: Python Application to Monitor Your Keyboard\n\n![GitHub top language](https://img.shields.io/github/languages/top/hmasdev/keyboard_monitor_app)\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/hmasdev/keyboard_monitor_app?sort=semver)\n![GitHub](https://img.shields.io/github/license/hmasdev/keyboard_monitor_app)\n![GitHub last commit](https://img.shields.io/github/last-commit/hmasdev/keyboard_monitor_app)\n\nKeyboard Monitor App is a Python package that allows monitoring and recording key combinations pressed on the keyboard. It uses the pynput library to listen for keyboard events.\n\nCAUTION: **DO NOT USE THIS APPLICATION TO MONITOR OTHERS' KEYBOARD INPUT**!\n\n## Installation\n\nTo install Keyboard Monitor App, use pip:\n\n```shell\npip install git+https://github.com/hmasdev/keyboard_monitor_app.git\n```\n\n## Usage\n\nKeyboard Monitor App can be used to monitor and record key combinations pressed on your keyboard. The recorded data can be saved as JSON files.\n\n### Simple Case\n\nIf you just want to record your keyboard input, you can run the following command:\n\n```bash\npython -m keyboard_monitor\n```\n\nYou can specify some options:\n\n```bash\npython -m keyboard_monitor --record-dir ${PATH_TO_DIREC_WHERE_YOU_WANT_TO_SAVE_RECORDS} --record-filename ${FILENAME_FORMAT_FOR_RECORDS} --log-level {LOG_LEVEL}\n```\n\n- `--record-dir`:\n\n  path to the directory where you want to save records from your keyboard;\n\n- `--record-filename`:\n\n  format of filenames of records which depend on `datetime` objects. For example, you can specify \"%Y%m%d%H%M%S.json\". Note that\n\n  1. this option also indicates how often to create a new file to record;\n  2. this option must end with the \".json\";\n\n- `--log-level`:\n\n  logging level. You can specify the following levels:\n\n  - `CRITICAL`\n  - `ERROR`\n  - `WARNING`\n  - `INFO`\n  - `DEBUG`\n\nYou can see the details of the optional arguments from the command line:\n\n```bash\npython -m keyboard_monitor --help\n```\n\n### Use `keyboard_monitor` in python codes\n\nYou can also use this application in your python codes.\nHere are 2 examples.\n\n- Simpler example:\n\n```python\n# import\nfrom keyboard_monitor.main import main as keyboard_monitor_main\n\n# run\nkeyboard_monitor_main(\n    record_dir='PATH TO DIREC',\n    record_filename='FILENAME FORMAT LIKE %Y%m%d%H%M%S',\n    log_level='INFO',\n)\n```\n\n- Complex exampe:\n\n```python\n# import\nfrom datetime import datetime\nfrom keyboard_monitor.key_combo_monitor import KeyComboMonitor\nfrom keyboard_monitor.keyboard_monitor import KeyboardMonitor\nfrom keyboard_monitor.recorder import JsonRecorder\n\n# create key combo monitor\nkey_combo_monitor = KeyComboMonitor()\n\n# create recorder\nrecorder = JsonRecorder(\n    direc=\"PATH2DIREC\",\n    datetime2filename=lambda dt: dt.strftime(\"FILENAME FORMAT %Y%m%d\"),\n)\n\n# create callback\ndef on_press_callback(key):\n    key_combo_monitor.activate_key(key)\n\ndef on_release_callback(key):\n    combo = key_combo_monitor.key_combo\n    key_combo_monitor.deactivate_key(key)\n    if not key_combo_monitor.combo_is_active():\n        recorder.record({\n            \"timestamp\": datetime.now().isoformat(),\n            \"combo\": [\n                {\n                    \"timestamp\": c.timestamp.isoformat(),\n                    \"keys\": [str(k) for k in c.keys],\n                }\n                for c in combo.combo\n            ]\n        })\n\n# create keyboard monitor\nkeyboard_monitor = KeyboardMonitor(\n    on_press_callback=on_press_callback,\n    on_release_callback=on_release_callback,\n)\n\n# run\nkeyboard_monitor.start()\n\n######\n\n# stop\nkeyboard_monitor.stop()\n```\n\n## Format of Record Keys\n\nRecorded keys are output to a JSON file in the specified directory.\n\nThe format of contents of the JSON file is as follows:\n\n```json\n[\n    {\n        \"timestamp\": \"%Y-%m-%dT%H:%M:%S.%f\",\n        \"combo\": [\n            {\n                \"timestamp\": \"%Y-%m-%dT%H:%M:%S.%f\",\n                \"keys\": [\"KEY1\"]\n            },\n            {\n                \"timestamp\": \"%Y-%m-%dT%H:%M:%S.%f\",\n                \"keys\": [\"KEY1\", \"KEY2\"]\n            },\n            ...\n        ]\n    },\n    ...\n]\n```\n\nNOTE: The definition of a key combo refers to a list of key combinations pressed between the state where no keys are pressed and the subsequent state where no keys are pressed again. For example, `[[\"KEY1\"],[\"KEY1\", \"KEY2\"],[\"KEY1\"]]` describe tapping \"KEY2\" with \"KEY1\" held.\n\n## LICENSE\n\nKeyboard Monitor is licensed under the [MIT](https://github.com/hmasdev/keyboard_monitor_app/tree/main/LICENSE) License. See the LICENSE file for more details.\n\n## Authors\n\n[hmasdev](https://github.com/hmasdev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmasdev%2Fkeyboard_monitor_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmasdev%2Fkeyboard_monitor_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmasdev%2Fkeyboard_monitor_app/lists"}