How do you detect keystrokes from a keyboard in DOS
-WITHOUT- using getch(). I am specifically trying to detect when the ALT Key is depressed, NOT an ALT+* event.
Compile and execute this program. And then it waits
a key input and you can press alt key at that time.
Hold the alt key and now press any key ( if you
use a dos console on Windows, esc, enter, space, ...
keys can give the special meaning to Windows so use
an alphabet or a digit key for this case. )
to return the 'getch' function. If this program
works fine for you, you can see the message
"Alt key was pressed".
Hee S. Chung
heesc@netian.com
You can detect whether ALT key is pressed or not
by using my source code. Surely you can capture
ALT without having to press another key. The
reason why I commented to use some other keys
is that, you need to confirm my source can
detect that ALT key is pressed.
As I mentioned it is very simple and fast
to detect ALT key is pressed.
if( *((char*)KEY_ADDRESS) & KEY_ALT ) {
/* alt key is pressed now */
}
KET_ADDRESS and KEY_ALT are defined in the
source which I previously supplied.
Above code is not related to other keys -
it just detect ALT key status.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.