
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Keyboard module in Python
In this article, we will learn about the use of the Keyboard module in Python 3.x. Or earlier.
Ide preferred − Jupyter notebook
Installation −
>>> pip install keyboard
Functionalities of the module −
- Allows us to block the action of specific keys
- We can manage intents from the keyboard using on click listeners.
- Cross-platform compatibility.
- Supports special & hotkeys available on the keyboard.
Now let’s implement this in the form of code −
Example
import keyboard # It writes the content keyboard.write("Tutorialspoint\n") # It writes end of line keyboard.press_and_release('shift + o, shift + y, \n') keyboard.press_and_release('k, j') # it blocks until ctrl keyboard.wait('Ctrl')
Output
Tutorialspoint O Y k j
Example
import keyboard # It writes the content keyboard.write("tutor\n") # It writes end of line keyboard.press_and_release('shift + a, shift + w, \n') keyboard.press_and_release('q, u') # it blocks until enter keyboard.wait('Enter')
Output
tutor A W q u
We can also use the record and the play method available in the keyboard module that can be directly imported into the console. In this way, we can also record keyboard activities. To know more details you may refer to https://pypi.org/project/keyboard/
Conclusion
In this article, we will learn about the application of the keyboard module in Python 3.x. Or earlier.
- Related Articles
- Reading Keyboard Input in Python
- Single-Row Keyboard in python
- Fraction module in Python
- colorsys module in Python
- Import module in Python
- struct module in Python
- Pygorithm module in Python
- __future__ Module in Python
- Keyboard shortcuts with Tkinter in Python 3
- Explain calendar module in python?
- The time Module in Python
- The calendar Module in Python
- The Threading Module in Python
- Import a module in Python
- OS Path module in Python

Advertisements