Using the Enter key to click a button

MINI LESSONS ›› Actions Editor ››

MINI LESSON

USING THE ENTER KEY TO CLICK A BUTTON

Instead of requiring a user to click on a button, it is possible to also allow them to simply press the Enter key.


DETAILS

It is possible to programmatically capture the "enter" key press and then in turn tell the button to essentially "click" itself.


For this to work the button has to be in focus - meaning that the little dashed focus rectangle must be visible around the edge of the button (see the image below). This tells ToolBook and tells the user which object on the screen currently has focus. The focus object changes as the user presses the Tab key on the keyboard.


 


If you are not seeing a focus rectangle around your particular button no matter how much you tab around the screen, ensure that the button is configured to be included in the Tab order.


 


Now for the magic - the way to programmatically tell the button to allow the Enter key to be used. To do this all you need to do is add a little bit of Actions Editor programming logic to the On Key Down event for that particular button.


The code below shows that it is looking for a keyCode value of 13 (which represents the Enter key) and if detected, the code will then Trigger the button - essentially causing the button to click itself.


 


Now anytime you have this button in Focus you can press the Enter Key to click it.



HOT TIP

In case you didn't know, it is a Windows standard behavior that any button in focus can be clicked simply by pressing the space bar.



Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation