Testing Which Function Key was Pressed

Sometimes when you are coding your own ISPF panel, you will have some specific processing that you want to perform depending on which function key is pressed. You can test this in the )PROC section of the panel definition by testing the value of .PFKEY which will contain a four character code identifying the function key pressed. Alternatively you can assign .PFKEY to a variable which can then be passed to a program attached to the panel rather than testing the value in the panel itself. For example:

 &PFKEY = .PFKEY 

.PFKEY is always assigned a value of four spaces in the )INIT and )REINIT sections of the panel. If a key other than a function key is pressed to trigger the processing then the field will still contain four spaces when the )PROC code is processed (for example if a PA key is pressed, the attention key is pressed, or if the enter key is pressed).

When you test the value in the )PROC section or in a program called from that section the value will be 'PF01' through 'PF24' indicating which of the 24 function keys was pressed. On many keyboards function keys 13 through 24 do not have their own keys but are instead obtained by holding down the shift key when you press one of the twelve function keys. In this instance the effect of holding down the shift key is to add 12 to the number of the function key pressed.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate