WGL.Q
Always use displayAddEventHandler instead, as displaySetEventHandler overwrites other (peoples') DEH.
Results appear below as you type; use the arrow keys to move through them.
Command · also in Event Handlers · Markdown · JSON · original wiki page
Sets given event handler of given display.
The return code of the provided function should indicate whether this event was handled correctly. This implies telling the engine whether it is default code should be executed.
See User Interface Event Handlers for the full list of handler names.
If applicable, see DIK KeyCodes for a list of key code constants, which are relevant to key related user interface events like onKeyDown and onKeyUp.
Important
When using the event names listed here with the ctrlAddEventHandler, ctrlSetEventHandler, displayAddEventHandler or displaySetEventHandler commands, the prefix "on" in the event name must be removed (e.g. 'ButtonDown' instead of 'onButtonDown').
display displaySetEventHandler [handlerName, function]
Parameters:
Returns: Nothing
_control displaySetEventHandler ["KeyDown", ""];
init.sqf:
KeysPressed = compile preprocessFile "keysPressed.sqf";
private _display = findDisplay 46;
_display displaySetEventHandler ["KeyDown", "_this call KeysPressed"];
keysPressed.sqf:
private _handled = false;
switch (_this select 1) do {
// F key
case 33: {
// code here
_handled = true;
};
};
_handled;
ListOfKeyCodes · displayAddEventHandler · displayRemoveEventHandler · displayRemoveAllEventHandlers · ctrlSetEventHandler · User Interface Event Handlers · DIK KeyCodes · keyName
Always use displayAddEventHandler instead, as displaySetEventHandler overwrites other (peoples') DEH.