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?
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...}
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()
Can't find a specific definition in the POSIX documentation for curses.
Try ' '
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With