System Utilities
C4Engine.h

class KeyboardEventHandler

The KeyboardEventHandler class encapsulates a keyboard event handler function.
Definition

class KeyboardEventHandler : public ListElement<KeyboardEventHandler>

Constructor

KeyboardEventHandler(HandlerProc *proc, void *data = nullptr);

Parameters
proc The procedure to invoke when a keyboard event occurs.
data The data which is passed to the event handler as its last parameter.
Description
The KeyboardEventHandler class encapsulates a procedure that is invoked when a keyboard event occurs. Once an instance of the KeyboardEventHandler class has been constructed, it can be installed by calling the Engine::InstallKeyboardEventHandler function.

When a keyboard event occurs, the procedures corresponding to all installed keyboard event handlers are invoked. The HandlerProc type is defined as follows.

typedef void HandlerProc(EventType eventType, long key, unsigned long modifiers, void *data);

The eventType parameter specifies what type of keyboard event occurred and can be one of the following values.
kEventKeyDown A key was pressed. If a key is held down long enough to trigger auto-repeat, then this event is received each time a character is generated.
kEventKeyUp A key was released.
kEventKeyCommand A command key combination was pressed. This means the user held in the control key (under Windows) or the command key (under Mac OS) while pressing another key.
The key parameter specifies the ASCII code corresponding to the key that was involved in the event. The modifiers parameter specifies which modifier keys were held down when the event occurred. It currently can be zero or the following value.
kModifierKeyShift The shift key was held down.
The data parameter is the value passed to the KeyboardEventHandler constructor.

A keyboard event handler is uninstalled by destroying its associated class instance.
Base Classes
ListElement<KeyboardEventHandler> Used internally to store all instances of KeyboardEventHandler in a list.