...
...
implementation
const
FKeys = [#59..#68];
SKeys = [vk_shift,vk_control,vk_menu,vk_capital];
Ctrl_Pressed = Left_Ctrl_Pressed OR Right_Ctrl_Pressed;
Alt_Pressed = Left_Alt_Pressed OR Right_Alt_Pressed;
var
InRec:TInputRecord;
LastKey:Char=#32;
LastScan:Char=#32;
CurMode,NormAttr:Word;
hStdIn:THandle = 0;
hStdOut:THandle = 0;
hStdErr:THandle = 0;
hConsole:Thandle = 0;
BI : TConsoleScreenBufferInfo;
AltKey:AnsiString = '-0123456789=abcdefghijklmnopqrstuvwxyz';
CvtKey:AnsiString = #130#129#120#121#122#123#124#125#126#127#128+
#131#30#48#46#32#18#33#34#35#23#36#37#38+
#50#49#24#25#16#19#31#20#22#47#17#45#21#44;
....
....
function KeyPressed : Boolean;
var
I : DWord;
begin
GetNumberofConsoleInputEvents(hStdIn,I);
Result:=I>0;
end;
function ReadKey : Char;
var
I : DWord;
OK : Boolean;
begin
if LastKey=#0 then
Result:=LastScan
else begin
{$ifdef VER120}
with InRec.Event.KeyEvent do begin
{$else}
with InRec.KeyEvent do begin
{$endif}
repeat
repeat
Ok:=ReadConsoleInput(hStdIn,InRec,1,I);
until OK and (InRec.EventType=KEY_EVENT) and
(bKeyDown=False);
LastScan:=Char(wVirtualScanCode);
until not (wVirtualKeyCode in SKeys);
Result:=AsciiChar;
if dwControlKeyState<>0 then begin
if Result=#0 then begin
if (dwControlKeyState and Shift_Pressed)<>0 then begin
if LastScan in FKeys then LastScan:=Char(Ord(LastScan)
+25);
end else if (dwControlKeyState and Ctrl_Pressed)<>0 then
begin
if LastScan in FKeys then
LastScan:=Char(Ord(LastScan)+35)
else case LastScan of
#55:LastScan:=#114;
#73:LastScan:=#132;
#75:LastScan:=#115;
#77:LastScan:=#116;
#79:LastScan:=#117;
#81:LastScan:=#118;
end;
end else if (dwControlKeyState and Alt_Pressed)<>0 then
begin
if LastScan in FKeys then LastScan:=Char(Ord(LastScan)
+45);
end;
end else begin
if (dwControlKeyState and Ctrl_Pressed)<>0 then begin
if Result in ['a'..'z'] then Result:=Char(Ord(Result)-
96)
end else if (dwControlKeyState and Alt_Pressed)<>0 then
begin
I:=Pos(Result,AltKey);
if I>0 then begin
LastScan:=CvtKey[I];
Result:=#0;
end;
end else if (dwControlKeyState and Shift_Pressed)<>0 then
begin
if Result=#9 then begin
Result:=#0;
LastScan:=#15;
end else CharUpper(PChar(Result));
end;
end;
end;
end;
end;
LastKey:=Result;
end;
Try a google searcg , if you can't find that i can send you the file,
or upload it.
patrick
Post by Richard Le Mesurier (Investec Employee Benefits)Nope, it actually does the same thing, except Readln moves the
cursor down a
Post by Richard Le Mesurier (Investec Employee Benefits)line...
I remember now that I am looking for the Delphi or API version of
repeat
until KeyPressed;
Anyone?