Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the key code for space bar in curses.h

Tags:

c

ncurses

curses

I just have a simple question, I cannot find what the key code is for space bar in curses.h. ex. I know the code for down is KEY_DOWN. can anyone help?

like image 309
wenincode Avatar asked Nov 17 '12 19:11

wenincode


3 Answers

There is no macro for the space key. Just use ' ' to represent a space. You can find a complete list of curses key macros here.

Ex.

char mychar = ' ';
if (mychar == ' ') {//Do this...}
like image 193
John Vulconshinz Avatar answered Oct 07 '22 15:10

John Vulconshinz


A couple of years late, but since this was the top hit when I was confused, I want to contribute! :-)

What you need to do is to use ord(c). For example:

c = getch()
if c == ord(' '):
    do_something()
like image 40
arve Avatar answered Oct 07 '22 14:10

arve


Can't find a specific definition in the POSIX documentation for curses.

Try ' '.

like image 30
pmg Avatar answered Oct 07 '22 15:10

pmg