Board index » delphi » Pressing Enter doesn't trigger OnKeyPress event

Pressing Enter doesn't trigger OnKeyPress event

I was trying to use the <Enter> key instead of <Tab> to do the editing.
Based on the FAQ I had, it used OnKeyPress event to check whether the key
is an <Enter> key (key = #13). I found out that an <Enter> key didn't
trigger the OnKeyPress event while an <ESC> key would do the trick. Then
I checked the online help and found out that an OnKeyPress event doesn't
support non-ASCII which I kind of doubted it.

If you have the same kind of problems, better suggestions or solutions, I
would like to hear from you. I would appreciate if you can mail me
directly on this regard. Thanks.

BTW, the version I use is 1.0.

Jack Shieh

 

Re:Pressing Enter doesn't trigger OnKeyPress event


Quote
Jack Shieh <jsh...@ix.netcom.com> wrote:
>I was trying to use the <Enter> key instead of <Tab> to do the editing.
>Based on the FAQ I had, it used OnKeyPress event to check whether the key
>is an <Enter> key (key = #13). I found out that an <Enter> key didn't
>trigger the OnKeyPress event while an <ESC> key would do the trick. Then
>I checked the online help and found out that an OnKeyPress event doesn't
>support non-ASCII which I kind of doubted it.

>If you have the same kind of problems, better suggestions or solutions, I
>would like to hear from you. I would appreciate if you can mail me
>directly on this regard. Thanks.

>BTW, the version I use is 1.0.

If I remember right, it's just that you cannot send Key back as <TAB>.
However, the following works:

procedure TForm1.EditKeyPress(Sender: TObject; var Key: Char);
begin
        if Key=#13
        then
                begin
                        key:=#0;
                        Perform(wm_NextDlgCtl,0,0);
                end;
end;

Good luck!

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Other Threads