Solved

kbhit() source code

Posted on 1997-05-09
3
1,553 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now