Solved

kbhit() source code

Posted on 1997-05-09
3
1,602 Views
Last Modified: 2013-12-04
I need C source code (not copyrighted) for a kbhit() function that will work on the Windows NT operating system.  Can you provide me with this source code?

Thanks in advance.
0
Comment
Question by:turk
3 Comments
 
LVL 4

Expert Comment

by:marko020397
ID: 1397244
Have you tried to CALL BIOS function which waits for keypress.
It is something like this.

union REGS in, out;
in.h.ah = 0x00;
int86 (0x16, &in, &out);

marko
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1397245
Win32 API has a function...

SHORT GetAsyncKeyState(
  int vKey // virtual-key code
);

which determines if a particular key is pressed.

Also there is ...

BOOL GetKeyboardState(
  PBYTE lpKeyState // address of array to receive status data
);

Which gives you current entire keyboard state, so you can see exactly which keys are up/down etc.

If you just want to respond to keys being hit, then handle WM_CHAR or WM_KEYUP/WM_KEYDOWN messages and so on.

0
 

Author Comment

by:turk
ID: 1397246
This at least tells me where to look for more informatin.  However, I am trying to port a program I wrote for the OS/2 operating system over to Windows NT.  It is not a GUI program.  I should have mentioned this.  Everything works but the _kbhit() function.  I was using the IBM CSet2 Compiler, and did not have the source for this one function.  What I really would like is the source to append to the end of my program so my program will compile and work without me having to do a lot of study, as I haven't used C for a long time.  I would be glad to change the grade to excellent and add 100 points for such source code.  Here is how I use the function in my source code:

if ((_kbhit()) != 0) {
           kb_ch = _getch();
           if (kb_ch == 27)
              exit(0);
}
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question