在C访问击键 [英] Access Keystrokes in C
问题描述
我试图访问C.击键我可以访问字母数字键。如何访问控制,Shift键和Alt键?
另外,我读的地方,有时候,而在控制台上,OS口罩退格键输入文本。我想知道用户pressed退格键。这不一样,知道什么时候的'\\ n'是pressed。
GNU C. Ubuntu的11。
I am trying to access keystrokes in C. I can access alphanumeric keys. How can I access Control, Shift and Alt key?
Plus I read somewhere that sometimes while entering text in console, OS masks backspace key. I would like to know where user pressed backspace key. It's not same as knowing when '\n' was pressed.
GNU C. Ubuntu 11.
推荐答案
迪特里希埃普回答评论:使用的ncurses 库
Dietrich Epp answered in a comment: use ncurses library.
又见<一个href=\"http://stackoverflow.com/questions/8242404/detect-meta-special-keys-ctrl-shift-alt-tab-esc-backspace-from-shell-in/8244551#8244551\">this问题
,你可能会做出 X11 客户端图形应用程序;在这种情况下使用图形工具库如 GTK 或的 Qt的
And you might make an X11 client graphical application; in that case use a graphical toolkit library like GTK or Qt
如果你想使一个控制台应用程序,使用 ncurses的或可能的 readline的
If you want to make a console application, use ncurses or perhaps readline
和你的问题,如果从字面上看,有没有意义:严格C标准不知道是什么一个键或一个按键是(唯一的I /在标准中提到O操作都涉及到 &LT;&stdio.h中GT;
直通文件
)。这就是为什么大多数人使用额外的库和标准(除了那些由ISO C要求的),例如。 的Posix ...
And your question, when taken literally, has no sense: the strict C standard don't know what a key or a keystroke is (the only I/O operations mentioned in the standard are related to <stdio.h>
thru FILE
). This is why most people uses additional libraries and standards (in addition of those required by ISO C), eg. Posix...
这篇关于在C访问击键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!