Solved

kbhit() source code

Posted on 1997-05-09
3
1,614 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…

739 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