Solved

kbhit() source code

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Mobile 6.5 device Apache Flex 3 44
Enable Clear Text in Win 8.1 7 41
Asp.net Form view Pager Template First Record 2 70
Alternative to visual sourcesafe 2 114
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now