home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
library
/
dos
/
keyboard
/
kbdhdr
/
kbdhdr.pas
< prev
Wrap
Pascal/Delphi Source File
|
1991-01-19
|
5KB
|
229 lines
(******************************************************************************
* kbdHdr *
* Common Keyboard interface unit symbolic names, ungetch routine *
******************************************************************************)
Unit kbdHdr;
Interface
Uses Crt;
Const
F1 = #187;
F2 = #188;
F3 = #189;
F4 = #190;
F5 = #191;
F6 = #192;
F7 = #193;
F8 = #194;
F9 = #195;
F10 = #196;
ALTF1 = #232;
ALTF2 = #233;
ALTF3 = #234;
ALTF4 = #235;
ALTF5 = #236;
ALTF6 = #237;
ALTF7 = #238;
ALTF8 = #239;
ALTF9 = #240;
ALTF10 = #241;
CTRLF1 = #222;
CTRLF2 = #223;
CTRLF3 = #224;
CTRLF4 = #225;
CTRLF5 = #226;
CTRLF6 = #227;
CTRLF7 = #228;
CTRLF8 = #229;
CTRLF9 = #230;
CTRLF10 = #231;
SHFTF1 = #212;
SHFTF2 = #213;
SHFTF3 = #214;
SHFTF4 = #215;
SHFTF5 = #216;
SHFTF6 = #217;
SHFTF7 = #218;
SHFTF8 = #219;
SHFTF9 = #220;
SHFTF10 = #221;
UPARROW = #200;
RIGHTARROW = #205;
LEFTARROW = #203;
DOWNARROW = #208;
HOME = #199;
PGUP = #201;
ENDKEY = #207;
PGDN = #209;
INS = #210;
DEL = #211;
TAB = #9;
ESC = #27;
ENTER = #13;
SYSREQ = #183;
CTRLMINUS = #31;
SPACE = #32;
CTRL2 = #129;
CTRL6 = #30;
BACKSPACE = #8;
BS = #8; {2 NAMES FOR BACKSPACE}
CTRLBACKSLASH = #28;
CTRLLEFTBRACKET = #27;
CTRLRIGHTBRACKET = #29;
CTRLBACKSPACE = #127;
CTRLBS = #127;
ALTA = #158;
ALTB = #176;
ALTC = #174;
ALTD = #160;
ALTE = #146;
ALTF = #161;
ALTG = #162;
ALTH = #163;
ALTI = #151;
ALTJ = #164;
ALTK = #165;
ALTL = #166;
ALTM = #178;
ALTN = #177;
ALTO = #152;
ALTP = #153;
ALTQ = #144;
ALTR = #147;
ALTS = #159;
ALTT = #148;
ALTU = #150;
ALTV = #175;
ALTW = #145;
ALTX = #173;
ALTY = #149;
ALTZ = #172;
CTRLA = #1;
CTRLB = #2;
CTRLC = #3;
CTRLD = #4;
CTRLE = #5;
CTRLF = #6;
CTRLG = #7;
CTRLH = #8;
CTRLI = #9;
CTRLJ = #10;
CTRLK = #11;
CTRLL = #12;
CTRLM = #13;
CTRLN = #14;
CTRLO = #15;
CTRLP = #16;
CTRLQ = #17;
CTRLR = #18;
CTRLS = #19;
CTRLT = #20;
CTRLU = #21;
CTRLV = #22;
CTRLW = #23;
CTRLX = #24;
CTRLY = #25;
CTRLZ = #26;
ALT1 = #248;
ALT2 = #249;
ALT3 = #250;
ALT4 = #251;
ALT5 = #252;
ALT6 = #253;
ALT7 = #254;
ALT8 = #255;
ALT9 = #167;
ALT0 = #168;
ALTMINUS = #169;
ALTEQ = #170;
SHIFTTAB = #143;
Function GetKey : Char;
procedure unGetKey(C : char);
procedure FlushKbd;
procedure flushBuffer;
const
hasPushedChar : boolean = false;
implementation
var
pushedChar : char;
(******************************************************************************
* FlushKbd *
******************************************************************************)
procedure FlushKbd;
var
C : char;
begin
hasPushedChar := False;
while (KeyPressed) do
C := GetKey;
end; {flushKbd}
(******************************************************************************
* flushBuffer *
* Same as above, but if key was pushed by eventMgr, know about it !! *
******************************************************************************)
procedure flushBuffer;
var
b : boolean;
begin
b := hasPushedChar;
flushKbd;
hasPushedChar := b;
end; {flushBuffer}
(******************************************************************************
* unGetKey *
* UnGetKey will put one character back in the input buffer. Push-back buffer *
* can contain only one character. *
* To avoid problems DO NOT CALL UNGETKEY WITHOUT FIRST CALLING GETKEY. If two *
* characters are pushed, the first is discarded. *
******************************************************************************)
procedure unGetKey;
begin
hasPushedChar := True;
pushedChar := c;
end; {unGetKey}
(******************************************************************************
* GetKey *
******************************************************************************)
function GetKey : Char;
var
c : Char;
Begin
if (hasPushedChar) then begin
GetKey := pushedChar;
hasPushedChar := False;
exit;
end;
c := ReadKey;
if (Ord(c) = 0) then Begin
c := ReadKey;
if c in [#128,#129,#130,#131]
then c := chr(ord(c) + 39)
else c := chr(ord(c) + 128); {map to suit keyboard constants}
End;
GetKey := c; {return keyboard (my..) code }
End; {getKey}
End.