Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

enter key

Posted on 2004-03-20
7
Medium Priority
?
316 Views
Last Modified: 2010-04-05
how do you simulate enter key pressed?
Example: If you have a  button..So when you hit enter
it behaves like you clicked on a button
0
Comment
Question by:Bosanac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10642321
Not sure what you really want, but you can test for a Enter key in your forms onKeyDown event

 procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if key = VK_RETURN then beep();
end;

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10642325
Explain more what you are trying to do~

Shane
0
 

Author Comment

by:Bosanac
ID: 10642840
To have enter click the button...
if key enter then button1.clickself on keydown...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:mokule
ID: 10643382
Button1.Default := True
All other buttons on a form should have Default := False
0
 

Expert Comment

by:Vatnam
ID: 10643505
Set the focus on the button you want like :

Button1.SetFocus

When you now press the enter key you'll get the normal button's 'on click' event.
0
 
LVL 17

Expert Comment

by:mokule
ID: 10643576
If You've got four edits and two buttons on a form.
You can do like this. If I understand what You mean.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit3.Text := Edit1.Text;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Edit4.Text := Edit2.Text;
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Button1.Default := True;
end;

procedure TForm1.Edit2Enter(Sender: TObject);
begin
  Button2.Default := True;
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
  Button1.Default := False;
end;

procedure TForm1.Edit2Exit(Sender: TObject);
begin
  Button2.Default := False;
end;

Marek
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 100 total points
ID: 10643623
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if key = VK_RETURN then Button1.click;
end;

OR

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
 if (Ord(Key) = VK_RETURN ) then Button1.Click
end;

Set forms KeyPreview = true

Shane
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question