大榕树 \ Pascal语言 \ Pascal练习
简单的按键检测子程序
原文链接:http://www.mydrs.org/program/list.asp?id=205
program KeyTest;{$A+,B-,E-,F-,G+,N+,O-,P+,T-,V-,X+}
{$D-,I-,L-,Q-,R-,S-,Y-}
{$M 65520,0,655360}uses
Dos;var
SaveKeyInterrupt:procedure;
Key:Byte;procedure KeyInterrupt;interrupt;
begin
Key:=Port[96];
inline($9C);{PUSHF----标志寄存器压栈}
SaveKeyInterrupt;
end;begin
Key:=0;
GetIntVec(9,@SaveKeyInterrupt);
SetIntVec(9,@KeyInterrupt);
WriteLn('Press ESC to exit');
repeat
if Key=1 then Break;
if (Key>0)and(Key<128) then
begin
WriteLn('You pressed a key of ',Key);
Key:=0;
end;
if Key>=128 then
begin
WriteLn('You unpressed a key of ',Key);
Key:=0;
end;
until False;
SetIntVec(9,@SaveKeyInterrupt);
end.
作者:陈世熹
来源:陈世熹的Pascal
时间:2001-09-02上一篇:简单的时钟控制子程序
下一篇:NOI2001在西北大学举行
大榕树 版权所有 ©1999-2006