Method XbpActiveXControl():keyDown() Foundation

Default event handler for ActiveX control event "KeyDown" (DISPID_KEYDOWN).

:keyDown( <nKey>, <nShift> ) --> self
<nKey> is the key code of the key being pressed. The key code is specified via constants used by the operating system .
A numeric value indicating the state of the SHIFT, ALT and CTRL keys at the time the key was pressed. A value of 1 indicates the SHIFT key was down, a value of 2 the CTRL was pressed and a value of 4 indicates the ALT key was depressed. The value in parameter <nShift> can be any combination of these values. 0 indicates neither key was down when the key was hit.

This method returns the object executing the method (self).


The event "KeyDown" (DISPID_KEYDOWN) is generated if a key is pressed by the user while an ActiveX control has the input focus. The default event handler :keyDown() transforms the numeric value in parameter <nKey> in one of the key code constants defined in APPEVENT.CH and generates the Xbase++ event xbeP_Keyboard. The event is posted to the current thread's message queue using the function PostAppEvent().

The method :keyDown() makes it possible for Xbase++ applications to react to ActiveX keyboard events as it does to normal keyboard events. All that is required to react to the event is to assign a code block to the callback slot :keyboard. Alternatively, event handling may be implemented in a method :keyboard() defined in a derived class.

Not all ActiveX controls support keyboard events. Controls that have the value OLECTRL_NOUIACTIVATE set in :controlFlags cannot be activated, for instance, and thus cannot receive keyboard input. In such cases, the method :keyDown() will not be called.


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.