Solved

Scancodes

Posted on 1998-11-30
5
277 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

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

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

19 Experts available now in Live!

Get 1:1 Help Now