Visual Servoing Platform  version 3.2.0 under development (2018-08-19)
vpKeyboard Class Reference

#include <visp3/io/vpKeyboard.h>

Public Member Functions

 vpKeyboard ()
 ~vpKeyboard ()
int kbhit ()
int getchar ()

Detailed Description

Keybord 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.

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

Definition at line 85 of file vpKeyboard.h.

Constructor & Destructor Documentation

vpKeyboard::vpKeyboard ( )

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

Definition at line 51 of file vpKeyboard.cpp.

vpKeyboard::~vpKeyboard ( )

Stops the raw mode.

Definition at line 56 of file vpKeyboard.cpp.

Member Function Documentation

int vpKeyboard::getchar ( )

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


Definition at line 62 of file vpKeyboard.cpp.

int vpKeyboard::kbhit ( )
1 : if a key was hit.

Definition at line 74 of file vpKeyboard.cpp.