12

I have simple question. How do you press a button with your enter key?

I have a login screen, where I can just login with a button. But I also want to login when pressing the enter button.

How should I do this?

Thanks in advance!

Jasper

johnny
  • 657
  • 7
  • 18
J Bom
  • 303
  • 1
  • 5
  • 21
  • 1
    You should also know that the `Cancel` property will make the button respond to the Escape key. In a dialog box with one OK button and one Cancel button, you most often set the OK button to `Default := true` and the Cancel button to `Cancel := true`. In addition, the modal results should be `ModalResult := mrOK` and `ModalResult := mrCancel`, respectively. – Andreas Rejbrand Mar 31 '11 at 15:42

1 Answers1

20

Set the button's Default property to True from Object Inspector.

Cosmin Prund
  • 25,498
  • 2
  • 60
  • 104
  • Where can I do that? Cause I have no idea? – J Bom Mar 31 '11 at 13:05
  • 3
    You select the button you want activated with the Enter key (probably an `Ok` or `LogIn` button), you go to your Object Inspector, find the `Default` property and select `True`. – Cosmin Prund Mar 31 '11 at 13:07