Solved

Scancodes

Posted on 1998-11-30
5
276 Views
Last Modified: 2010-04-01
How can I get keyboard input in msdos wich get pressed keys to the keyboard buffer where I could read them afterwards? some kind of interrupt without delay? not in asm please..
0
Comment
Question by:miikkal
5 Comments
 
LVL 2

Expert Comment

by:pjmaze
ID: 1178905
can you use Asm ?


0
 
LVL 1

Expert Comment

by:MatthewL
ID: 1178906
Hi Miikkal;

By delay, do you mean the routine waits for the key to be pressed?


if so then int 16H, AH=1 will do the trick ( after the call AL= scan code, AH = ascii if ZF is set )

e.g.

char readChar( void )
{
    char temp= (char) 0;  // return zero if no key pressed

    asm {
                   mov ah,0x01
                   int 0x16
                   jnz skip
                   mov temp,al
           }
 
   skip:

   return( temp );
}


Matt

0
 

Author Comment

by:miikkal
ID: 1178907
Edited text of question
0
 

Author Comment

by:miikkal
ID: 1178908
Edited text of question
0
 

Accepted Solution

by:
Mithander earned 100 total points
ID: 1178909
#include<conio.h>

void main(void)
{
char ch=0;
int count = 0;
while(ch!='\n')
{
if(kbhit())
{
  ch=getch();
  cout << "You pressed the " << ch << " key." << endl;
}
cout << count << endl;
}
}

Let me know if you need something else
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 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

16 Experts available now in Live!

Get 1:1 Help Now