Skip to main content

A simple cross-platform library to block and unblock keyboard input.

Project description

KeyboardGat

A simple, cross-platform Python library to temporarily block and unblock keyboard input in the terminal.

This can be useful for scenarios where you want to prevent user input during a critical operation or create a more controlled command-line interface.

How to Use

Install the package from PyPI:

pip install KeyboardGat

Here is a basic example of how to use KeyboardGat:

from KeyboardGat import KeyboardGate
import time

# Initialize the gate
gate = KeyboardGate()

print("Keyboard input will be disabled for 3 seconds.")
gate.KeyboardGateDisable()
time.sleep(3)
gate.KeyboardGateEnable()
print("Keyboard input is now enabled.")

# You can also use it as a context manager
with KeyboardGate():
    print("Input is disabled inside this block.")
    time.sleep(2)
print("Input is automatically re-enabled outside the 'with' block.")

How It Works

  • On Unix-like systems (Linux, macOS): It modifies the terminal's attributes (termios) to turn off ECHO, which prevents characters from being displayed.
  • On Windows: It uses the msvcrt module to consume any keyboard events that are waiting in the input buffer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keyboardgat-0.0.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keyboardgat-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file keyboardgat-0.0.1.tar.gz.

File metadata

  • Download URL: keyboardgat-0.0.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for keyboardgat-0.0.1.tar.gz
Algorithm Hash digest
SHA256 95a00c5212c6dc7bf41e011ea7321a226770d36c4bf656526259bfc142a95f46
MD5 7175e818f613c3ecf5c2a6eef7bf91a7
BLAKE2b-256 840e4132c2ff25a31ce0a8d57b2babd10b958d2d58461d08d7c55071f9234acc

See more details on using hashes here.

File details

Details for the file keyboardgat-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: keyboardgat-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for keyboardgat-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc2eac4cabefe8329b1774084ab8966fd995086e01064bcc29e5fcdb7885cc96
MD5 03e1a172cfbd8fca1c3aadc2fb7fb352
BLAKE2b-256 feedb74a14f8ae5ebad3ec40d7f7c529100de51f980f4023f2ee9e829d1385c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page