[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

Use ENTER instead of TAB

what can I do to use ENTER instead of the TAB key to switch from one component to another (for instance Edits).
My Users prefer it that way.
0
chachote
Asked:
chachote
  • 2
  • 2
1 Solution
 
intheCommented:
hi,
on your tedits or whatever OnKeyPress event do

 If key=chr(13) then
SendMessage(handle,WM_NEXTDLGCTL,0,0);


Regards Barry
0
 
intheCommented:
better:

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
If key= #13 then begin
SendMessage(handle,WM_NEXTDLGCTL,0,0);
key := #0;  //to stop the beep
end;
end;

0
 
DrDelphiCommented:
This will make the for act exactly as if a tab were pressed:

{Add this to KEYdown event handler for all controls you wish to use enter key}

if (key=13) then postmessage(handle,WM_KeyDown,VK_TAB,0);


Good luck!!
0
 
chachoteAuthor Commented:
Barry

This is good but your next was the best
0
 
chachoteAuthor Commented:
All answers work, But Barry's is the
best!
Now I improved it by writing it on the Form's OnKeyPress Event, then choose that event for the OnKeyPress event of the controls I want.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now