# Triggering Events While Typing

> *You're reading the documentation of an older/legacy version, Text Animator 1.X.  To read the latest version, please visit this page instead* [2.X (EN)](https://docs.febucci.com/text-animator-unity/2.x/)*. How to update:* [Upgrading from 1.X to 2.X](/text-animator-unity/2.x/other/changelog/upgrading-from-1.x-to-2.x.md)

***

Events are special tags that let you send messages (string) to any listener script, once the typewriter has reached a specific part of the text. *(For this reason, events work only if the typewriter is enabled)*

***

## Overview

You can write events in your text by using rich text tags.

### Formatting

Event's messages are preceded by a question mark, like this: `<?eventMessage>`.

**Example:** To call an event named 'shakeCamera', write: `<?shakeCamera>`

* 👍🏻 An event can have any kind of tag, including built-in effect's ones.
* ⚠️ Events are case sensitive. Writing `<?camshake>` is not the same as writing `<?camShake>`

***

## Listening to events

The scripts that you want listen to TextAnimator events/messages must subscribe to the `onEvent` callback, inside the `TextAnimator` class. (Scripting Api)

Example:

```csharp

//Inside your script

public TextAnimator textAnimator;

//Manage the event subscription

private void Awake()
{
    textAnimator.onEvent += OnEvent;
}

private void OnDestroy()
{
    textAnimator.onEvent -= OnEvent;
}

//Do things based on messages
void OnEvent(string message)
{
    switch (message)
    {
        case "something":
            //do something
            break;
    }
}
```

👍🏻 Note how the "message" string has no ‘<‘, ‘?’ and ‘>’ characters, but only contains the message.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.febucci.com/text-animator-unity/1.x/typewriter/triggering-events-while-typing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
