utility for getting the exact keycodes as according to ncurses.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
818B

  1. /* nckey.c - displays the current key according to ncurses
  2. * @BAKE cc -Wall -Wextra -Wpedantic -pipe -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 $@ -o $* -lncurses -ltinfo
  3. */
  4. #include <signal.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <unistd.h>
  8. #include <ncurses.h>
  9. int
  10. main (void)
  11. {
  12. int c, c2, run = 1;
  13. initscr();
  14. raw();
  15. noecho();
  16. notimeout(stdscr, TRUE);
  17. keypad(stdscr, TRUE);
  18. notimeout(stdscr, FALSE);
  19. ESCDELAY = 0;
  20. mvprintw(0, 0, "type q (113) to exit. everything is in decimal.");
  21. while (run)
  22. {
  23. c = getch();
  24. mvprintw(1, 0, " ");
  25. if (c == 'q')
  26. { run = 0; }
  27. if (c == 27)
  28. {
  29. mvprintw(1, 0, "ESC");
  30. c2 = getch();
  31. mvprintw(1, 4, "%.3d %c", c2, c2);
  32. }
  33. else
  34. { mvprintw(1, 0, "%.3d %c", c, c); }
  35. refresh();
  36. }
  37. endwin();
  38. }