home *** CD-ROM | disk | FTP | other *** search
- Unit ExtKey;
-
- { TP4 Unit: EXTKEY.PAS / Author: David Bennett / Date: 2-9-88 / Version 1.0
- {
- { This unit is a "Primitive" but very effective way to access most of the
- { extended key values using Turbo Pascal Version 4.0. See text for a more
- { descriptive documentation. Released to the public domain.
- }
-
- Interface
-
- Uses
- Crt;
-
- { The constants below can be used by your program to test for a particular
- { extended key value
- }
-
- Const
- Alt_A=$011E; Alt_B=$0130; Alt_C=$012E; Alt_D=$0120; Alt_E=$0112;
- Alt_F=$0121; Alt_G=$0122; Alt_H=$0123; Alt_I=$0117; Alt_J=$0124;
- Alt_K=$0125; Alt_L=$0126; Alt_M=$0132; Alt_N=$0131; Alt_O=$0118;
- Alt_P=$0119; Alt_Q=$0110; Alt_R=$0113; Alt_S=$011F; Alt_T=$0114;
- Alt_U=$0116; Alt_V=$012F; Alt_W=$0111; Alt_X=$012D; Alt_Y=$0115;
- Alt_Z=$012C;
-
- UpKey =$0148; DownKey =$0150;
- LeftKey =$014B; RightKey =$014D;
- Ctrl_LeftKey =$0173; Ctrl_RightKey =$0174;
- InsKey =$0152; DelKey =$0153;
- HomeKey =$0147; EndKey =$014F;
- PageUp =$0149; PageDown =$0151;
- Ctrl_HomeKey =$0177; Ctrl_EndKey =$0175;
- Ctrl_PageUp =$0184; Ctrl_PageDown =$0176;
-
- F1=$013B; F2=$013C; F3=$013D; F4=$013E; F5=$013F; F6=$0140; F7=$0141;
- F8=$0142; F9=$0143; F10=$0144;
-
- Shift_F1=$0154; Shift_F2=$0155; Shift_F3=$0156; Shift_F4=$0157;
- Shift_F5=$0158; Shift_F6=$0159; Shift_F7=$015A; Shift_F8=$015B;
- Shift_F9=$015C; Shift_F10=$015D;
-
- Alt_F1=$0168; Alt_F2=$0169; Alt_F3=$016A; Alt_F4=$016B; Alt_F5=$016C;
- Alt_F6=$016D; Alt_F7=$016E; Alt_F8=$016F; Alt_F9=$0170; Alt_F10=$0171;
-
- Ctrl_F1=$015E; Ctrl_F2=$015F; Ctrl_F3=$0160; Ctrl_F4=$0161; Ctrl_F5=$0162;
- Ctrl_F6=$0163; Ctrl_F7=$0164; Ctrl_F8=$0165; Ctrl_F9=$0166; Ctrl_F10=$0167;
-
- Var
- ExtendedKey, { Returns true if last key was extended false if not }
- ASCIIKey : Boolean; { Returns exactly opposite of ExtendedKey }
-
- Function ExtendKey : Word;
- { * This procedure returns the extended key board value. If the keypressed
- { * was an extended keyboard code, it will return a $01 (ESC) in the
- { * High byte.
- }
-
- Implementation
-
- { * This procedure returns the extended key board value. If the keypressed
- { * was an extended keyboard code, it will return a $01 in the high byte.
- { * If an extended key was pressed the ExtendedKey will return true. If
- { * an ASCII key was pressed the ASCIIKey will return true.
- }
- Function ExtendKey : Word;
- Var
- Ch : Char;
- Result : Word;
- Begin
- Ch := #00;
- Ch := ReadKey;
- If (Ch = #00) Then Begin
- Ch := ReadKey;
- Result := $0100+Ord(Ch);
- ExtendedKey := True;
- End Else Begin
- Result := Ord(Ch);
- ExtendedKey := False;
- End;
- ASCIIKey := Not(ExtendedKey);
- ExtendKey := Result;
- End;
-
- End. {Implementation}