whichTrigger trigger
whichPlayer player
key oskeytype
metaKey integer

Bitfield. MetaKeys are "none"(0), "shift"(1), "control"(2), "alt"(4) and "META"(8) (Windows key). They can be combined 2 + 4 = 6. The player needs to hold all specified metakeys to trigger the event.

keyDown boolean

If keyDown = false: trigger is called once when key is released (unpressed). If keyDown = true: calls trigger repeatedly while key is being held down. In V1.31.1 this happens once. In V1.32.10 repeats until released at approximately 30 times per second and fluctuating.


Registers event to call trigger when player presses a key + metakey. Key presses are synced by the game between players automatically.

Meta keys are modifier keys like CTRL, SHIFT, ALT. See BlzGetTriggerPlayerMetaKey. If you just want a key press without them, use 0.

Example (Lua):

trg_key = CreateTrigger()
-- prints oskey as object, metakey as integer
TriggerAddAction(trg_key, function() print(BlzGetTriggerPlayerKey(),  BlzGetTriggerPlayerMetaKey()) end)

-- register key press ESCAPE
BlzTriggerRegisterPlayerKeyEvent(trg_key, Player(0), OSKEY_ESCAPE, 0, false)

-- register key press CTRL+1
BlzTriggerRegisterPlayerKeyEvent(trg_key, Player(0), OSKEY_1, 2, false)

return type
Source code
native BlzTriggerRegisterPlayerKeyEvent            takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event