keyboard


Namekeyboard JSON
Version 0.13.5 PyPI version JSON
download
home_pagehttps://github.com/boppreh/keyboard
SummaryHook and simulate keyboard events on Windows and Linux
upload_time2020-03-23 21:47:06
maintainer
docs_urlNone
authorBoppreH
requires_python
licenseMIT
keywords keyboard hook simulate hotkey
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            
keyboard
========

Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more.

## Features

- **Global event hook** on all keyboards (captures keys regardless of focus).
- **Listen** and **send** keyboard events.
- Works with **Windows** and **Linux** (requires sudo), with experimental **OS X** support (thanks @glitchassassin!).
- **Pure Python**, no C modules to be compiled.
- **Zero dependencies**. Trivial to install and deploy, just copy the files.
- **Python 2 and 3**.
- Complex hotkey support (e.g. `ctrl+shift+m, ctrl+space`) with controllable timeout.
- Includes **high level API** (e.g. [record](#keyboard.record) and [play](#keyboard.play), [add_abbreviation](#keyboard.add_abbreviation)).
- Maps keys as they actually are in your layout, with **full internationalization support** (e.g. `Ctrl+รง`).
- Events automatically captured in separate thread, doesn't block main program.
- Tested and documented.
- Doesn't break accented dead keys (I'm looking at you, pyHook).
- Mouse support available via project [mouse](https://github.com/boppreh/mouse) (`pip install mouse`).

## Usage

Install the [PyPI package](https://pypi.python.org/pypi/keyboard/):

    pip install keyboard

or clone the repository (no installation required, source files are sufficient):

    git clone https://github.com/boppreh/keyboard

or [download and extract the zip](https://github.com/boppreh/keyboard/archive/master.zip) into your project folder.

Then check the [API docs below](https://github.com/boppreh/keyboard#api) to see what features are available.


## Example


```py
import keyboard

keyboard.press_and_release('shift+s, space')

keyboard.write('The quick brown fox jumps over the lazy dog.')

keyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))

# Press PAGE UP then PAGE DOWN to type "foobar".
keyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar'))

# Blocks until you press esc.
keyboard.wait('esc')

# Record events until 'esc' is pressed.
recorded = keyboard.record(until='esc')
# Then replay back at three times the speed.
keyboard.play(recorded, speed_factor=3)

# Type @@ then press space to replace with abbreviation.
keyboard.add_abbreviation('@@', 'my.long.email@example.com')

# Block forever, like `while True`.
keyboard.wait()
```

## Known limitations:

- Events generated under Windows don't report device id (`event.device == None`). [#21](https://github.com/boppreh/keyboard/issues/21)
- Media keys on Linux may appear nameless (scan-code only) or not at all. [#20](https://github.com/boppreh/keyboard/issues/20)
- Key suppression/blocking only available on Windows. [#22](https://github.com/boppreh/keyboard/issues/22)
- To avoid depending on X, the Linux parts reads raw device files (`/dev/input/input*`)
but this requires root.
- Other applications, such as some games, may register hooks that swallow all 
key events. In this case `keyboard` will be unable to report events.
- This program makes no attempt to hide itself, so don't use it for keyloggers or online gaming bots. Be responsible.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/boppreh/keyboard",
    "name": "keyboard",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "keyboard hook simulate hotkey",
    "author": "BoppreH",
    "author_email": "boppreh@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/79/75/c969f2258e908c39aadfc57d1cb78247dc49e6d36371bb3a48c194640c01/keyboard-0.13.5.zip",
    "platform": "",
    "description": "\nkeyboard\n========\n\nTake full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more.\n\n## Features\n\n- **Global event hook** on all keyboards (captures keys regardless of focus).\n- **Listen** and **send** keyboard events.\n- Works with **Windows** and **Linux** (requires sudo), with experimental **OS X** support (thanks @glitchassassin!).\n- **Pure Python**, no C modules to be compiled.\n- **Zero dependencies**. Trivial to install and deploy, just copy the files.\n- **Python 2 and 3**.\n- Complex hotkey support (e.g. `ctrl+shift+m, ctrl+space`) with controllable timeout.\n- Includes **high level API** (e.g. [record](#keyboard.record) and [play](#keyboard.play), [add_abbreviation](#keyboard.add_abbreviation)).\n- Maps keys as they actually are in your layout, with **full internationalization support** (e.g. `Ctrl+\u00e7`).\n- Events automatically captured in separate thread, doesn't block main program.\n- Tested and documented.\n- Doesn't break accented dead keys (I'm looking at you, pyHook).\n- Mouse support available via project [mouse](https://github.com/boppreh/mouse) (`pip install mouse`).\n\n## Usage\n\nInstall the [PyPI package](https://pypi.python.org/pypi/keyboard/):\n\n    pip install keyboard\n\nor clone the repository (no installation required, source files are sufficient):\n\n    git clone https://github.com/boppreh/keyboard\n\nor [download and extract the zip](https://github.com/boppreh/keyboard/archive/master.zip) into your project folder.\n\nThen check the [API docs below](https://github.com/boppreh/keyboard#api) to see what features are available.\n\n\n## Example\n\n\n```py\nimport keyboard\n\nkeyboard.press_and_release('shift+s, space')\n\nkeyboard.write('The quick brown fox jumps over the lazy dog.')\n\nkeyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))\n\n# Press PAGE UP then PAGE DOWN to type \"foobar\".\nkeyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar'))\n\n# Blocks until you press esc.\nkeyboard.wait('esc')\n\n# Record events until 'esc' is pressed.\nrecorded = keyboard.record(until='esc')\n# Then replay back at three times the speed.\nkeyboard.play(recorded, speed_factor=3)\n\n# Type @@ then press space to replace with abbreviation.\nkeyboard.add_abbreviation('@@', 'my.long.email@example.com')\n\n# Block forever, like `while True`.\nkeyboard.wait()\n```\n\n## Known limitations:\n\n- Events generated under Windows don't report device id (`event.device == None`). [#21](https://github.com/boppreh/keyboard/issues/21)\n- Media keys on Linux may appear nameless (scan-code only) or not at all. [#20](https://github.com/boppreh/keyboard/issues/20)\n- Key suppression/blocking only available on Windows. [#22](https://github.com/boppreh/keyboard/issues/22)\n- To avoid depending on X, the Linux parts reads raw device files (`/dev/input/input*`)\nbut this requires root.\n- Other applications, such as some games, may register hooks that swallow all \nkey events. In this case `keyboard` will be unable to report events.\n- This program makes no attempt to hide itself, so don't use it for keyloggers or online gaming bots. Be responsible.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Hook and simulate keyboard events on Windows and Linux",
    "version": "0.13.5",
    "split_keywords": [
        "keyboard",
        "hook",
        "simulate",
        "hotkey"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "1668622367c3381c5f12947a4196ac65",
                "sha256": "8e9c2422f1217e0bd84489b9ecd361027cc78415828f4fe4f88dd4acd587947b"
            },
            "downloads": -1,
            "filename": "keyboard-0.13.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1668622367c3381c5f12947a4196ac65",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 58098,
            "upload_time": "2020-03-23T21:47:05",
            "upload_time_iso_8601": "2020-03-23T21:47:05.023344Z",
            "url": "https://files.pythonhosted.org/packages/55/88/287159903c5b3fc6d47b651c7ab65a54dcf9c9916de546188a7f62870d6d/keyboard-0.13.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "d0d1c7a6f34e664f5cedea9a2838da0c",
                "sha256": "63ed83305955939ca5c9a73755e5cc43e8242263f5ad5fd3bb7e0b032f3d308b"
            },
            "downloads": -1,
            "filename": "keyboard-0.13.5.zip",
            "has_sig": false,
            "md5_digest": "d0d1c7a6f34e664f5cedea9a2838da0c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 71798,
            "upload_time": "2020-03-23T21:47:06",
            "upload_time_iso_8601": "2020-03-23T21:47:06.614324Z",
            "url": "https://files.pythonhosted.org/packages/79/75/c969f2258e908c39aadfc57d1cb78247dc49e6d36371bb3a48c194640c01/keyboard-0.13.5.zip",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-03-23 21:47:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "boppreh",
    "github_project": "keyboard",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "lcname": "keyboard"
}
        
Elapsed time: 0.05027s