unit key; interface uses dos; const scEsc = 001; scF1 = 059; scF2 = 060; scF3 = 061; scF4 = 062; scF5 = 063; scF6 = 064; scF7 = 065; scF8 = 066; scF9 = 067; scF10 = 068; scF11 = 087; scF12 = 088; scScrlLock = 070; { Upper Row } scTilde = 041; sc1 = 002; sc2 = 003; sc3 = 004; sc4 = 005; sc5 = 006; sc6 = 007; sc7 = 008; sc8 = 009; sc9 = 010; sc0 = 011; scMinus = 012; scEqual = 013; scBackSpace = 014; { QWERTY Row } scTab = 015; scQ = 016; scW = 017; scE = 018; scR = 019; scT = 020; scY = 021; scU = 022; scI = 023; scO = 024; scP = 025; scOpenSq = 026; scCloseSq = 027; scEnter = 028; { Home Row } scCapsLock = 058; scA = 030; scS = 031; scD = 032; scF = 033; scG = 034; scH = 035; scJ = 036; scK = 037; scL = 038; scSemicolon = 039; scQoute = 040; { Bottom Key Row } scLShift = 042; scBackSlash = 043; scZ = 044; scX = 045; scC = 046; scV = 047; scB = 048; scN = 049; scM = 050; scComma = 051; scPeriod = 052; scSlash = 053; scRShift = 054; { Spacebar Row } scCtrl = 029; scAlt = 056; scSpace = 057; { Numeric Keypad } scHome = 071; scUp = 072; scPgUp = 073; scLeft = 075; scKey5 = 076; scRight = 077; scEnd = 079; scDown = 080; scPgDn = 081; scNumLock = 069; scGrayMinus = 074; scGrayPlus = 078; scAsterisk = 055; scIns = 082; scDel = 083; var pressed : array [0..127] of boolean; lastpressed : byte; lastreleased : byte; saveint09 : procedure; procedure int09handler; interrupt; procedure install_handler; procedure restore_handler; implementation procedure int09handler; Begin asm in al,60h mov dl,al mov al,20h out 20h,al cmp dl,0E0h je @@finish xor dh,dh mov si,dx and si,007Fh test dl,80h jnz @@released mov [lastpressed],dl mov al,true jmp @@savestate @@released: and dl,7Fh mov [lastreleased],dl mov al,false @@savestate: mov ds:byte ptr [pressed+si],al @@finish: { pushf} End; { SaveInt09;} end; procedure install_handler; Begin FillChar(Pressed,SizeOf(Pressed),False); GetIntVec(9,@SaveInt09); SetIntVec(9,@int09handler); End; {asm xor ax,ax mov di,offset pressed mov cx,(128+1+1)/2 cld segds rep stosw cli mov es,ax mov ax,es:[09h*4] mov bx,es:[09h*4+2] mov word ptr [saveint09],ax mov word ptr [saveint09+2],bx mov es:word ptr [09h*4],offset int09handler mov es:word ptr [09h*4+2],cs sti end;} procedure restore_handler; Begin SetIntVec(9,@SaveInt09); End; { asm cli xor ax,ax mov es,ax mov ax,word ptr [saveint09] mov bx,word ptr [saveint09+2] mov es:[09h*4],ax mov es:[09h*4+2],bx sti end;} end.