Bigozs
asked on
Catching ALT keypress
Hi All,
I need to catch ALT pressed using interrupts (16H ), no idea on how, any input appriciated, thanks.
I need to catch ALT pressed using interrupts (16H ), no idea on how, any input appriciated, thanks.
Hi, I have written a keyboard handler for interrupt 9... It can read multiple keypresses at the same time, it can read any key that the keyboard has as well... It's written to replace/intercept with interrupt 9 though, If you want it... pass me your E-mail.
ASKER
unfortunately i need this for 16h :(
Const KBD_INT = $16;
ALT_MASK = $08;
Function IsAltPressed : Boolean;
Var
Status : Byte;
Begin
asm
mov ah, $2
int KBD_INT
mov Status, al
end;
If ((Status and ALT_MASK) > 0) Then
IsAltPressed := True
Else
IsAltPressed := False;
End;
----------------
Happy programming,
Ido.
ALT_MASK = $08;
Function IsAltPressed : Boolean;
Var
Status : Byte;
Begin
asm
mov ah, $2
int KBD_INT
mov Status, al
end;
If ((Status and ALT_MASK) > 0) Then
IsAltPressed := True
Else
IsAltPressed := False;
End;
----------------
Happy programming,
Ido.
You can do it without any interrupt (so faster). The state of Alt key ( and some other keys ) placed in this address :
0040:0017 in the BIOS Data Area.
bit mask
0: 01H right-shift
1: 02H left-shift
2: 04H Ctrl
3: 08H Alt
4: 10H ScrollLock
5: 20H NumLock
6: 40H CapsLock
var
i:byte;
begin
i:=mem[$0040:$0017];
if (i and 8)=0 then
write('Alt key is pressed');
end.
Actually interrupt 16 function 2 uses
this address. There is another address
which can test difference between right
and left Alts.
0040:0017 in the BIOS Data Area.
bit mask
0: 01H right-shift
1: 02H left-shift
2: 04H Ctrl
3: 08H Alt
4: 10H ScrollLock
5: 20H NumLock
6: 40H CapsLock
var
i:byte;
begin
i:=mem[$0040:$0017];
if (i and 8)=0 then
write('Alt key is pressed');
end.
Actually interrupt 16 function 2 uses
this address. There is another address
which can test difference between right
and left Alts.
ASKER
Idok- this would work, but the thing is i need no ASM in it.
Kamarey- it has to be interrupts, not my idea, just been asked to do it that way =)
Thanks for the effort though, i know i didn't specify no Assembly :) sorry
Kamarey- it has to be interrupts, not my idea, just been asked to do it that way =)
Thanks for the effort though, i know i didn't specify no Assembly :) sorry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh well.
did I propose an answer to this question...? I thought I only posted a comment. I'm Sorry for that Idok.
ASKER
oops, something went wrong?
sorry :(
sorry :(
ASKER
oops, something went wrong?
sorry :(
sorry :(
Sure, hypo, no hard feelings.
Some you win, some you lose. ;-)
Bigozs: Ofcouse not - you got an answer to your problem, that's what this place is all about.
Some you win, some you lose. ;-)
Bigozs: Ofcouse not - you got an answer to your problem, that's what this place is all about.