The IKeyboardHandler class processes all types of keyboard events.
Create a handler derived from IKeyboardHandler and attach it to any window whose keyboard events you want to handle. You can do this by calling IHandler::handleEventsFor to pass the window to the keyboard handler.
You can attach IKeyboardHandlers to the following controls:
When the keyboard handler receives a keyboard event, it creates an object of IKeyboardEvent and routes that object to the appropriate IKeyboardHandler virtual function. You can override these virtual functions to supply your own specialized processing of these events.
A keyboard event continues to travel up the owner chain until either a handler stops it or the key is processed by the window itself. As a result, an IKeyboardHandler object should not stop the processing of any key event that it does not specifically process because the key has the potential of being handled by any window in the owner chain, such as the frame window.
The return value from the virtual functions specifies whether the keyboard event is passed on for additional processing, as follows:
Some types of key processing, such as peeking at or modifying key input prior to its being stored in a control, are best handled by using the class ITextChangeHandler.
You can attach IKeyboardHandlers to I3StateCheckBox objects.
Some types of key processing, such as peeking at or modifying key input prior to its being stored in a control, are best handled by using the class ITextChangeHandler.
You can construct and destruct objects of this class.
![]() |
public:
virtual ~IKeyboardHandler()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IKeyboardHandler()
Provides the default constructor.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
The Open Class Library dispatches events that have been sent or posted to a window to the handlers attached to that window. It does this by calling the event-dispatching function of the handler objects. An IKeyboardHandler object processes only keyboard-related events.
![]() |
protected:
virtual bool dispatchHandlerEvent(IEvent& event)
If a keyboard event is received, this function calls the appropriate virtual function.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
A keyboard handler contains event-processing members that you can use
to provide application-specific processing for a keyboard event.
Override at least one of these virtual functions
in a derived class.
Note:
![]() |
protected:
virtual bool characterKeyPress(IKeyboardEvent& event)
Implemented by derived classes to handle character key presses. When using this callback function, you do not have to verify the character code value using IKeyboardEvent::isCharacter. This function can only be called for key-down transitions or if the user holds down a key (IKeyboardEvent::isUpTransition returns false).
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual bool key(IKeyboardEvent& event)
Implemented by derived classes to handle any and all unprocessed key events. This function lets you process every keystroke as it is entered as well as key-down and key-up transitions (see IKeyboardEvent::isUpTransition for details).
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual bool scanCodeKeyPress(IKeyboardEvent& event)
Implemented by derived classes to handle scan code key presses. When using this callback function, you do not have to verify that the event contains a scan code value using IKeyboardEvent::isScanCode. This function can only be called for key-down transitions or if the user holds down a key (IKeyboardEvent::isUpTransition returns false).
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual bool virtualKeyPress(IKeyboardEvent& event)
Implemented by derived classes to handle virtual key presses. When using this callback function, you do not have to verify that the event contains a virtual key value using IKeyboardEvent::isVirtual. This function can only be called for key-down transitions or if the user holds down a key (IKeyboardEvent::isUpTransition returns false).
Windows | OS/2 | AIX |
Yes | Yes | Yes |
virtual ~IHandler()
virtual IString asDebugInfo() const
virtual IString asString() const
virtual IHandler& disable()
virtual IHandler& enable(bool enable = true)
virtual IHandler& handleEventsFor(IWindow* window)
IHandler()
bool isEnabled() const
virtual IHandler& stopHandlingEventsFor(IWindow* window)
virtual IEventResult defaultProcedure(IEvent& event)
virtual bool dispatchHandlerEvent(IEvent& event) = 0