Keyboard

class gpype.backend.sources.keyboard.Keyboard[source]

Bases: EventSource

Keyboard input for capturing key press and release events.

Monitors key press and release events and converts them to numbers: a press emits the key’s Windows virtual-key code, on every platform, and a release emits 0. So the arrow keys are 37 to 40 (left, up, right, down) on Windows, macOS and Linux alike. A key Windows has no code for emits -1.

On macOS the app that runs Python – Terminal, or your IDE – needs Input Monitoring (System Settings > Privacy & Security). Without it no key arrives and nothing fails. pynput’s warning that the process must be added to accessibility clients names the wrong permission.

class Configuration[source]

Bases: Configuration

Configuration class for Keyboard source parameters.

class Keys[source]

Bases: Keys

Configuration key constants for the Keyboard source.

__init__(edge_id=None, **kwargs)[source]

Initialize keyboard event source.

Parameters:
  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional configuration parameters for EventSource.

start()[source]

Start keyboard event monitoring.

Initializes and starts keyboard listeners for press and release events in background threads.

stop()[source]

Stop keyboard event monitoring and cleanup resources.

Stops keyboard listeners and waits for their threads to complete.