Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Handling User Input : Changing the function of a key
 

Changing the function of a key

You can globally change ABL key functions by modifying your environment. For more information on modifying your environment, see the chapter on colors and fonts in this book and the chapter on user interface environments in OpenEdge Deployment: Managing ABL Applications.
Although ABL has defined functions for several of the keys on your keyboard, you can redefine those keys to perform other functions within an application. In addition, you can assign functions to any of the other keyboard keys.
Suppose the user is accustomed to pressing F2 to get help information and F1 to signal that they are finished entering data. Although the AVM usually treats F2 as GO and F1 as HELP, you can switch the functions of those keys as demonstrated in the i-action.p procedure.
i-action.p
ON F1 GO.
ON F2 HELP.
ON CTRL-X BELL.

FOR EACH Customer NO-LOCK:
  DISPLAY Customer.CustNum.
  UPDATE Customer.Name Customer.CreditLlimit Customer.SalesRep.
END.
In this procedure, the ON statements redefine the function of F1, F2, and CTRL+X. Run this procedure, then press F1. You can see that F1 now performs the GO function, normally performed by F2. If you press CTRL+X, the AVM rings the terminal bell. The new key definitions are in effect for the duration of the session, unless you redefine them. Also, on UNIX, any key label you use in an ON statement must have an entry in the PROTERMCAP file for your terminal.
When you use the ON statement, you use the name of the key whose function you are redefining, followed by the action you want to take when the user presses that key, as shown in the following figure.
Figure 21. Key function syntax and meaning
The i-action.p procedure uses three actions: GO, HELP, and BELL. There are many other actions you can use when redefining the function of a key. The following table lists these actions.
Table 38. Actions you assign to keys
Action
Default key
BACKSPACE
BACKSPACE
BACK–TAB
SHIFT+TAB, CTRL+U, CODE+TAB
BELL
CLEAR
F8, CTRL+Z, CODE+Z
CURSOR–UP
×, CTRL+K
CURSOR–DOWN
±, CTRL+J
CURSOR–LEFT
?, CTRL+H
CURSOR–RIGHT
?, CTRL+L
DELETE–CHARACTER
DEL
ENDKEY
END–ERROR
F4, CTRL+E, CODE+E, ESC (Windows)
ERROR
GO
F2, CTRL+X, CODE+X
HELP
F1, HELP, CTRL+W, CODE+W
HOME
HOME, ESC H (UNIX)
INSERT–MODE
F3, INSERT, CTRL+T, OVERTYPE
RECALL
F7, CTRL+R, CODE+R
RETURN
RETURN
STOP
CTRL+BREAK (Windows), CTRL+C (UNIX)
TAB
TAB, CTRL+I