Skip to content

Instantly share code, notes, and snippets.

@gagbo
Created September 28, 2019 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gagbo/c5ab3b3a5d8b11eb47ab8879745acf69 to your computer and use it in GitHub Desktop.
Save gagbo/c5ab3b3a5d8b11eb47ab8879745acf69 to your computer and use it in GitHub Desktop.
Get keycodes in terminal
#include <stdio.h>
#include <curses.h>
#include <ncurses.h>
#include <locale.h>
#include <wchar.h>
int main()
{
setlocale(LC_CTYPE, ""); initscr(); raw(); noecho(); keypad(stdscr, TRUE);
wint_t c;
get_wch(&c);
endwin();
printf("Keycode: %d\n", c);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment