访问 C 中的击键 [英] Access Keystrokes in C
问题描述
我正在尝试访问 C 中的击键.我可以访问字母数字键.如何访问 Control、Shift 和 Alt 键?
另外,我在某处读到有时在控制台中输入文本时,操作系统会屏蔽退格键.我想知道用户在哪里按下退格键.这与知道何时按下 '
' 不同.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 '
' was pressed.
GNU C. Ubuntu 11.
推荐答案
Dietrich Epp 在评论中回答:使用 ncurses 库.
Dietrich Epp answered in a comment: use ncurses library.
另请参阅 这个问题
您可能会制作一个 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 操作与
到 FILE
).这就是为什么大多数人使用额外的库和标准(除了 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屋!