Keyboard

class Keyboard(self)

Bases: pybind11_object

Keyboard management under unix (Linux or OSX). This class is not available under windows.

Gets a key from the keyboard without waiting for the “Enter” key.

Warning

The key that was pressed is only detected if the terminal where the binary was launched is active.

vpKeyboard keyboard; // Turn on keyboard raw mode
int c;
while (...) {
  ...
  if (keyboard.kbhit()) { // Detect if a key was pressed
    c = keyboard.getchar (void); // Get the pressed key
    if (c == 'q' || c == 'Q') {
      break; // Quit the while()
    }
  ...
  }
}

// Keyboard raw mode is turned off by the vpKeyboard destructor

Activates the raw mode to read keys in an non blocking way.

Methods

__init__

Activates the raw mode to read keys in an non blocking way.

getchar

Get the hit key.

kbhit

return:

1 : if a key was hit.

Inherited Methods

Operators

__doc__

__init__

Activates the raw mode to read keys in an non blocking way.

__module__

Attributes

__annotations__

__init__(self)

Activates the raw mode to read keys in an non blocking way.

getchar(self) int

Get the hit key. kbhit() indicates if a key was hitten.

kbhit(self) int
Returns:

1 : if a key was hit.