home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PAS_0593
/
CTRL_ALT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
2KB
|
88 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 327 of 410
From : Wilbert van Leijen 2:281/256.14 12 May 93 21:01
To : Jason Duke 1:381/102.0
Subj : Scanning for CTRL- and ALT- keys
────────────────────────────────────────────────────────────────────────────────
08 May 93, Jason Duke writes to All:
JD> HEy, I have been using some routines to check if certain keys are pressed,
JD> but I can't figure out how to test for ALT and CTRL key combinations.
JD> Anyone want to give me some help?}
{$G+ }
uses Dos, Crt;
Var
KeyHandlerProc : Procedure;
Int15Vector : Pointer;
Const
AltStatus : Array[Boolean] of String[5] = (' ', ' ALT ');
CtrlStatus : Array[Boolean] of String[6] = (' ', ' CTRL ');
Procedure KeyHandler; Far;
Var
AltKey : Boolean;
CtrlKey : Boolean;
WhereXY : Record
x, y : Byte;
end;
Begin
AltKey := False;
CtrlKey := False;
ASM
MOV AH, 2
INT 16h
CMP AL, 8
JNE @1
INC [AltKey]
@1: CMP AL, 4
JNE @2
INC [CtrlKey]
@2:
end;
WhereXY.x := WhereX;
WhereXY.y := WhereY;
GotoXY(66, 25);
Write(AltStatus[AltKey], ' ', CtrlStatus[CtrlKey]);
GotoXY(WhereXY.x, WhereXY.y);
end; { KeyHandler }
{ This INT 15h handler is called every time a key is pressed -
provided you're not running this program on an XT-class machine }
Procedure TrapKeyboard; Assembler;
ASM
PUSH BX
PUSH DS
PUSHF
MOV BX, SEG @Data
MOV DS, BX
CMP AH, 4Fh
JNE @ChainInt15
PUSH ES
PUSHA
CALL [KeyHandlerProc]
POPA
POP ES
@ChainInt15:
PUSHF
CALL [Int15Vector]
POPF
POP DS
POP BX
IRET
end; { TrapKeyboard }
Begin
GetIntVec($15, Int15Vector);
KeyHandlerProc := KeyHandler;
SetIntVec($15, @TrapKeyboard);
ReadLn;
SetIntVec($15, Int15Vector);
end.