Taking in Text Input

Started by
6 comments, last by StonerSunshine 20 years, 9 months ago
I''m currently working on an OpenGL game project, and I need to be able to take in text input from the user. I tried using the _kbhit() function along with _getch() but they didn''t work at all. (The _kbhit() function never picked up when a key was hit. Maybe because I''m using Windows XP?) Does anyone know of a good way to take in text from the user other than an "if" check for every keyboard key? Thanks in advance for any help.
Advertisement
The _kbhit and _getch functions are low level borland library functions that bypass the console to get input before the console does.

See, this is your problem; you have no console since you are running a windows application. Thus, you must use the Windows event handler to pick up keypresses. You must have an event handler, otherwise you won''t have a validly working windows application.

-----------------------------
Final Frontier Trader
-----------------------------Final Frontier Trader
If I were you, I would look into DirectInput. You can make a rather simple keyboard input routine for around, fifteen lines (give or take).
There are some good tutorials in the articles section, and the help files with DirectX SDK aren''t all that bad...

I don''t have a signature, sorry.
the future is just like the past, just later. - TANSTAAFL
Either that, or google for getAsyncKeyState(). This function allows you to query for any keypress.
Thanks for the replies. I see... So, maybe I can use the Windows WM_KEYDOWN message to know when a key is hit. Is there a function that can tell me specifically which character was hit when the WM_KEYDOWN message is sent?
WM_CHAR???
I know about WM_CHAR, but aren''t Windows messages UINTs? I''m trying to get a "char" that I can append to the string that is being printed onscreen. Is there a call that can convert that UINT value into a char?
Handle WM_KEYDOWN, and the wParam (IIRC) parameter of your window proc contains the virtual key code for the key that was pressed.

This topic is closed to new replies.

Advertisement