C语言 curses.h 中空格键的关键代码是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13434254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 04:28:09  来源:igfitidea点击:

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

cncursescurses

提问by wenincode

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?

我只是有一个简单的问题,我在curses.h 中找不到空格键的关键代码是什么。前任。我知道 down 的代码是 KEY_DOWN。有人可以帮忙吗?

回答by John Vulconshinz

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.

空格键没有宏。只需使用 ' ' 表示一个空格。您可以在此处找到 Curses 键宏的完整列表。

Ex.

前任。

char mychar = ' ';
if (mychar == ' ') {//Do this...}

回答by arve

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:

您需要做的是使用 ord( c)。例如:

c = getch()
if c == ord(' '):
    do_something()

回答by pmg

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

POSIX 文档中找不到针对 curses的特定定义。

Try ' '.

试试' '