ALT Key
ALT Key
(OP)
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.
-WITHOUT- using getch(). I am specifically trying to detect when the ALT Key is depressed, NOT an ALT+* event.
RE: ALT Key
#include <stdio.h>
#include <conio.h>
#define KEY_ADDRESS 0x417 /* ROM BIOS data address */
#define KEY_RSHIFT 0x01
#define KEY_LSHIFT 0x02
#define KEY_CTRL 0x04
#define KEY_ALT 0x08
#define KEY_SCROLL 0x10
#define KEY_NUMLOCK 0x20
#define KEY_CAPSLOCK 0x40
#define KEY_INS 0x80
int main( void )
{
getch();
if( *((char*)KEY_ADDRESS) & KEY_ALT ) {
puts( "Alt key was pressed" );
}
return 0;
}
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
http://www.netian.com/~heesc
RE: ALT Key
RE: ALT Key
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.
Thanks.
Hee S. Chung
heesc@netian.com
http://www.netian.com/~heesc
RE: ALT Key
by doing:
while(1) {
sleep(1);
if( *((char*)KEY_ADDRESS) & KEY_ALT ) {
//bla
}
}
it clearly does work, thanks alot ;-)
RE: ALT Key
Thank you! Enjoy your programming!
Hee S. Chung
heesc@netian.com
http://www.netian.com/~heesc