控制台键盘命中检测和解释 [英] Console Keyboard hit detection and interpretting
问题描述
嘿,所以它被推荐给我,我应该使用kdhit()函数来检测控制台窗口中的按键:
Hey so it's been reccomended to me that i should use the kdhit() function to detect a keypress in a console window:
如果是Windows,kbhit ()函数是你想要的家伙,如果是* nix,这里是一个kbhit()模拟器kbhit()立即返回一个标志,说有没有一个键盘字符等待被读取可以测试该标志,看看是否应该发出键盘读取。
"If it's Windows, the kbhit( ) function is the guy you want. If it's *nix, here's a kbhit( ) emulator. kbhit( ) returns immediately (no blocking) with a flag that says that there is or is not a keyboard character waiting to be read. You can test the flag to see if you should issue a keyboard read."
然而,我想知道最简单,希望标准的读取键缓冲区的方式,调用标志。任何提示? 谢谢!
However i would like to know the easiest, hopefully standard way of reading the key buffer or what he calls the flag. Any tips? Thanks!
推荐答案
使用_kbhit()测试是否按下某个键。和当它使用_getch()来获取值。 (注意_getch()可以为特殊键返回0或0xE0,并为该值再次调用_getch()。
用于在使用_getche()时显示字符。
Use _kbhit() to test if a key is pressed. and when it is use _getch() to get the value. (note _getch() can return 0 or 0xE0 for special keys and call _getch() again for that value) for displaying the characters while reading use _getche().
这篇关于控制台键盘命中检测和解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!