Language Reference Guide : Events : KeyDown Event
 
Share this page          
KeyDown Event
The KeyDown event is triggered whenever OpenROAD receives a WM_KEYDOWN or WM_SYSKEYDOWN message. The event is not queued but is generated immediately. Information about the key is stored in a KeyDownData object, which is delivered to the 4GL program in the MessageObject attribute of the FrameExec.
This event has the following syntax:
on KeyDown
The following attribute of the Event class can be used in the KeyDown event block:
MessageObject
Specifies a KeyDownData object that contains information about the key that caused the KeyDown event
The 4GL event code has the opportunity to stop further processing of the WM_KEYDOWN or WM_SYSKEYDOWN message by modifying the KeyDownData object. To discard the message, set the KeyDownData.VirtualKey to zero. The PrintScrn key does not cause a KeyDown event, and no other events are generated in conjunction with a KeyDown event. In particular, the KeyDown event does not cause either a SetValue or a ChildSetValue event.
For a listing of virtual key codes and their values, see Virtual Key Values.
In the following example processing of the 'A' Key is stopped:
/* the virtual key code for the A key is 65.  */
on KeyDown =
declare
     KeyData    = KeyDownData default NULL;
     VirtualKey = integer not null;
enddeclare
begin
     KeyData    = KeyDownData(CurFrame.MessageObject);
     VirtualKey = KeyData.VirtualKey;
     /*  No further processing of the A key  */
     if (VirtualKey = 65) then
          KeyData.VirtualKey = 0;
     endif;
end
More information:
MessageObject Attribute