~riderius/cpp-code

ref: 11395c93e77d6608146c91d960ecd0a14eb5e2a6 cpp-code/keylog.cpp -rw-r--r-- 394 bytes
11395c93RIDERIUS Added ncurses prog: keylog 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <locale>
#include <ncurses.h>

int main(void) {
  setlocale(LC_ALL, "");
  initscr();
  clear();
  noecho();

  printw("Enter a symbol\nExit: ESC");
  refresh();
  char ch;
  WINDOW *win = newwin(LINES / 2 - 1, COLS / 2 - 4, LINES / 2 - 1, COLS / 2 - 4);
  while ((ch = wgetch(win)) != 27) {
    wclear(win);
    wprintw(win, "%s = %d", keyname(ch), ch);
  }
  endwin();
  return 0;
}