?
Solved

kbhit() source code

Posted on 1997-05-09
3
Medium Priority
?
1,658 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 200 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

777 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