Link to home
Start Free TrialLog in
Avatar of Bigozs
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.
Avatar of Hypo
Hypo
Flag of Sweden image

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.
Avatar of Bigozs
Bigozs

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.
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.
Avatar of Bigozs

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
ASKER CERTIFIED SOLUTION
Avatar of Hypo
Hypo
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh well.
did I propose an answer to this question...? I thought I only posted a comment. I'm Sorry for that Idok.
Avatar of Bigozs

ASKER

oops, something went wrong?

sorry :(
Avatar of Bigozs

ASKER

oops, something went wrong?

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.