

Determine if a key has been pressed and store this in a variable.

If no key has been pressed, the program should continue without waiting.




unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    SavedPressedKey: Char;
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  SavedPressedKey := Key;
end;
 
end.