Getch returns -1?

They asked how to capture keys such as F11 or insand getchr, returns nothing for these keys, and I can’t find anything while working, which takes the original input from input events.

Now I am trying to execute ncurses / curses in a C ++ program to capture these keys.

My testing program is simple, it basically:

#include <stdlib.h>
#include <stdio.h>
#include <curses.h>
int main() {
    int car;
    while(c != '\b') {
        c = getch();
        printf("%i", c);
    }
    return 0;
}

I use it, of course, just like the other getch () function, but it returns -1infinite time .. I use the last core in Arch linux in the standard terminal (also tested in xterm),

Is there some kind of switch that I need to enable in order to use this getch () in libraries?

+3
source share
1

initscr(); getch().

, , , , cbreak(); noecho(); ( cbreak).

+7

Source: https://habr.com/ru/post/1776132/


All Articles