SRL Archive - FAQ

Need help with KeyDown or KeyPress


EGM

2010-11-25 00:30:54

I'm trying to capture and read Ctrl+key while and perform an action depending on key. I've tried both OnKeyDown and OnKeyPress events attached to a TMemo control, but both methods hang Simba the way I'm using them.

procedure OnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (ssCtrl in Shift) then
case Key of
'n': writeln('New');
'o': writeln('Open');
's': writeln('Save');
end;
end;
procedure OnKeyPress(Sender: TObject; var Key: char);
begin
if IsKeyDown(VK_CONTROL) then
case Key of
'n': writeln('New');
'o': writeln('Open');
's': writeln('Save');
end;
end;

Suggestions?

~EGM