Skip to content

Instantly share code, notes, and snippets.

@voldyman
Created May 12, 2013 08:22
Show Gist options
  • Save voldyman/5562836 to your computer and use it in GitHub Desktop.
Save voldyman/5562836 to your computer and use it in GitHub Desktop.
get ascii code for keys
// gcc -o arrow arrow.c -lcurses
#include <curses.h>
#include <stdio.h>
int main(void)
{
int ch = 0;
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
printw("Type a key. Use 'q' to quit\n");
while (ch != 'q') {
ch = getch();
printw("You typed: '%c' which is ASCII %d\n", (char) ch, ch);
}
endwin();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment