0

>>>>The function you posted will return the ascii code, not the scan codes

I still say that, it returns, scan code
try with any character key like 'A','s', etc.
& guess, they r same for any keyboard!

0

> Is there any way to detect this without using winAPI or any other standard APIs???
No there isn't.
Standard C doesn't know about keyboards, mice, screens or other advanced stuff like that.

It has an input stream, which is usually buffered, so there goes the "immediate" requirement.
It also has no control over what the environment chooses to stuff into that input stream. So whilst some keyboard keys make it (say 'A'), others do not (say a cursor key). Likewise, mouse positions are completely foreign.

So at the very least, you have to use whatever your OS / Platform gives you. So for example, to do this in a win32 console, you would use functions like ReadConsoleInput
If you don't like having a big black rectangle in the middle of the screen, then you're going to have to look at writing say a service (with perhaps its own little icon in the system tray), making use of hook functions.

0

>>>>The function you posted will return the ascii code, not the scan codes

I still say that, it returns, scan code
try with any character key like 'A','s', etc.
& guess, they r same for any keyboard!

int 16 returns the scan code in ah and the ascii value in al. If you really want the ascii value then get it from al. When the value of ah is 0 that means someone hit one of the special keys, such as function and arrow keys. In that case you have to call int 16 a second time to get its values. The ascii value of special keys are the same as normal keys. There are several ways to handle that -- one way is to add 255 to the ascii value of special keys, another way I've seen is to make them a negative value. You have to do that so that the rest of the program knows how to interpret the value returned by that function.

0

u want the code for c/vc++ ?
I hav a code (for c), which detects mouse activities.

sorry i couldn`t reply earlier.... i wanted to do this completely in C.

Thanks.

0

sorry i couldn`t reply earlier.... i wanted to do this completely in C.

Thanks.

so want the code or not ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.