---
name: "addUserActionEventHandler"
type: command
status: ok
groups: ["Event Handlers"]
arma3_since: "2.06"
locality: {"argument": null, "effect": "local", "server_exec": false}
source: https://community.bistudio.com/wiki/addUserActionEventHandler
revid: 378187
updated: 2026-03-10T13:05:46Z
---

# addUserActionEventHandler

*Command · Event Handlers · Arma 3 v2.06*

Locality: effect **local**

## Description

Adds a user action event handler to the current mission and returns its event handler index.

## Syntax

```sqf
addUserActionEventHandler [keyName, event, expression]
```

**Parameters:**

- `keyName`: [String](../topics/String.md) - action key name - see inputAction/actions
- `event`: [String](../topics/String.md) - event name - see [UserAction Event Handlers](../topics/Event_Handlers.md#useraction-event-handlers). Can be one of:
  - `"Activate"`
  - `"Deactivate"`
  - `"Analog"`
- `expression`: [Code](../topics/Code.md) - expression that will be executed in [missionNamespace](../commands/missionNamespace.md) when event handler fires.
  - `_thisEventHandler` returns the event handler index
  - `_thisEvent` returns the event type (the *event* parameter, either `"Activate"`, `"Deactivate"` or `"Analog"`)

**Returns:** [Number](../topics/Number.md) - the index of the currently added UserAction event handler is returned

## Examples

### Example 1

```sqf
private _ehId = addUserActionEventHandler ["ReloadMagazine", "Activate", { systemChat "reloading!"; }];
```

## See also

[removeUserActionEventHandler](../commands/removeUserActionEventHandler.md) · [removeAllUserActionEventHandlers](../commands/removeAllUserActionEventHandlers.md) · [Arma 3: Event Handlers](../topics/Event_Handlers.md)

<sub>Source: [BI Community Wiki — addUserActionEventHandler](https://community.bistudio.com/wiki/addUserActionEventHandler) (revision 378187).</sub>
