home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PASCAL / VSAFE.ZIP / KEYNAMER.PAS < prev    next >
Pascal/Delphi Source File  |  1990-12-17  |  3KB  |  103 lines

  1. unit keynamer;
  2.  
  3. {***********************************************************************}
  4. { KeyName returns a descriptive string for each kbxxxx constant defined }
  5. { in Turbo Vision.                                                      }
  6. { Copyright (c) 1990 by Danny Thorpe                                    }
  7. {***********************************************************************}
  8.  
  9. interface
  10.  
  11. uses drivers;
  12.  
  13.  
  14. function KeyName( key: word): string;
  15.  
  16.  
  17.  
  18. implementation
  19.  
  20.  
  21. function KeyName( key: word): string;
  22.   const QWERTY: string[10] = 'QWERTYUIOP';
  23.         ASDF: string[9] = 'ASDFGHJKL';
  24.         ZXCV: string[7] = 'ZXCVBNM';
  25.   var st: string;
  26.   begin
  27.   KeyName:='';
  28.   case key of
  29.     0..31: KeyName:= 'Control-'+char(key+64);
  30.        32: KeyName:= 'Spacebar';
  31.   33..125: KeyName:= char(key);
  32.     $011B: KeyName:= 'kbEsc';
  33.     $0200: KeyName:= 'kbAltSpace';
  34.     $0400: KeyName:= 'kbCtrlIns';
  35.     $0500: KeyName:= 'kbShiftIns';
  36.     $0600: KeyName:= 'kbCtrlDel';
  37.     $0700: KeyName:= 'kbShiftDel';
  38.     $0E08: KeyName:= 'kbBack';
  39.     $0E7F: KeyName:= 'kbCtrlBack';
  40.     $0F00: KeyName:= 'kbShiftTab';
  41.     $0F09: KeyName:= 'kbTab';
  42.     $1C0A: KeyName:= 'kbCtrlEnter';
  43.     $1C0D: KeyName:= 'kbEnter';
  44.     $4700: KeyName:= 'kbHome';
  45.     $4800: KeyName:= 'kbUp';
  46.     $4900: KeyName:= 'kbPgUp';
  47.     $4A2D: KeyName:= 'kbGrayMinus';
  48.     $4B00: KeyName:= 'kbLeft';
  49.     $4D00: KeyName:= 'kbRight';
  50.     $4E2B: KeyName:= 'kbGrayPlus';
  51.     $4F00: KeyName:= 'kbEnd';
  52.     $5000: KeyName:= 'kbDown';
  53.     $5100: KeyName:= 'kbPgDn';
  54.     $5200: KeyName:= 'kbIns';
  55.     $5300: KeyName:= 'kbDel';
  56.     $7200: KeyName:= 'kbCtrlPrtSc';
  57.     $7300: KeyName:= 'kbCtrlLeft';
  58.     $7400: KeyName:= 'kbCtrlRight';
  59.     $7500: KeyName:= 'kbCtrlEnd';
  60.     $7600: KeyName:= 'kbCtrlPgDn';
  61.     $7700: KeyName:= 'kbCtrlHome';
  62.     $8200: KeyName:= 'kbAltMinus';
  63.     $8300: KeyName:= 'kbAltEqual';
  64.     $8400: KeyName:= 'kbCtrlPgUp';
  65.     $0000: KeyName:= 'kbNoKey';
  66.   else
  67.     begin
  68.     if lo(key) = 0 then
  69.       begin
  70.       key:= hi(key);
  71.       case key of
  72.         $10..$19:  KeyName:= 'kbAlt'+ QWERTY[key-$F];
  73.         $1E..$26:  KeyName:= 'kbAlt'+ ASDF[key-$1D];
  74.         $2C..$32:  KeyName:= 'kbAlt'+ ZXCV[key-$2B];
  75.         $3B..$44:  begin
  76.                    str((key-$3A):0,st);
  77.                    KeyName:= 'kbF'+st;
  78.                    end;
  79.         $54..$5D:  begin
  80.                    str((key-$53):0,st);
  81.                    KeyName:= 'kbShiftF'+st;
  82.                    end;
  83.         $5E..$67:  begin
  84.                    str((key-$5D):0,st);
  85.                    KeyName:= 'kbCtrlF'+st;
  86.                    end;
  87.         $68..$71:  begin
  88.                    str((key-$67):0,st);
  89.                    KeyName:= 'kbAltF'+st;
  90.                    end;
  91.         $78..$81:  begin
  92.                    str((key-$77):0,st);
  93.                    KeyName:= 'kbAlt'+st;
  94.                    end;
  95.         end;  {case}
  96.       end;
  97.     end;
  98.   end; {case}
  99. end;
  100.  
  101.  
  102.  
  103. end.