 Отзывы присылать на склад нитроманита nitromanit@mail.ru

Unit keyboard;

interface

function inkey:word;
function waitkey:word;

const
      KEYOFF=511;
      ESC=283;
      ENTER=269;
      BACKSPACE=264;
      TAB=265;
      INSERT=338;
      DELETE=339;
      SPACE=32;
      altX=301;
      PgUP=329;
      PgDOWN=337;
      CtrlPgUP=388;
      CtrlPgDOWN=374;
      HOME=327;
      aEND=335;
      CtrlHOME=375;
      CtrlEND=373;
      UP=328;
      DOWN=336;
      LEFT=331;
      RIGHT=333;
      ALTUP=408;
      ALTDOWN=416;
      ALTLEFT=411;
      ALTRIGHT=413;
      CTRLUP=397;
      CTRLDOWN=401;
      CTRLLEFT=371;
      CTRLRIGHT=372;
      F1=315;
      F2=316;
      F3=317;
      F4=318;
      F5=319;
      F6=320;
      F7=321;
      F8=322;
      F9=323;
      F10=324;
      F11=389;
      F12=390;
      SHIFTF1=340;
      SHIFTF2=341;
      SHIFTF3=342;
      SHIFTF4=343;
      SHIFTF5=344;
      SHIFTF6=345;
      SHIFTF7=346;
      SHIFTF8=347;
      SHIFTF9=348;
      SHIFTF10=349;
      SHIFTF11=391;
      SHIFTF12=392;
      CTRLF1=350;
      CTRLF2=351;
      CTRLF3=352;
      CTRLF4=353;
      CTRLF5=354;
      CTRLF6=355;
      CTRLF7=356;
      CTRLF8=357;
      CTRLF9=358;
      CTRLF10=359;
      CTRLF11=393;
      CTRLF12=394;
      altF1=360;
      altF2=361;
      altF3=362;
      altF4=363;
      altF5=364;
      altF6=365;
      altF7=366;
      altF8=367;
      altF9=368;
      altF10=369;
      altF11=395;
      altF12=396;

implementation

function inkeys:word;assembler;
asm
    mov ah,6    { если AH=0 то это символ алфавита в AL }
    mov dl,0ffh { если AH=1 то это управляющая клавиша в AL }
    int 21h
    jnz @k1
    mov ax,511 {ax=keyoff}
    jmp @nd
@k1:cmp al,0
    jz  @k2
    mov ah,0
    jmp @nd
@k2:int 21h
    mov ah,1
@nd:
end;

function inkey:word;
var key:word;
begin
key:=inkeys;
if key=KEYOFF then begin inkey:=key;exit;end;
if key>=128 then begin inkey:=key;exit;end;
  case key of
    27:inkey:=ESC;
    13:inkey:=ENTER;
     8:inkey:=BACKSPACE;
     9:inkey:=TAB;
  else inkey:=key;
  end;
end;

function waitkey:word;
var key:word;
begin
key:=inkey;
while key=511 do key:=inkey;
waitkey:=key;
end;

end.